Randomness in built-in .sort

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jan 5 18:43:05 PST 2009


Benji Smith wrote:
> dsimcha wrote:
>> == Quote from Bill Baxter (wbaxter at gmail.com)'s article
>>> Actually, a function to sort multiple arrays in parallel was exactly
>>> what I was implementing using .sort.  So that doesn't sound like a
>>> limitation to me at all.   :-)
>>> --bb
>>
>> Am I (and possibly you) the only one(s) who think that sorting 
>> multiple arrays in
>> parallel should be standard library functionality?  The standard 
>> rebuttal might be
>> "use arrays of structs instead of parallel arrays".  This is a good 
>> idea in some
>> situations, but for others, parallel arrays are just plain better.  
>> Furthermore,
>> with D's handling of variadic functions, generalizing any sort to 
>> handle parallel
>> arrays is easy.
> 
> I've written my own parallel-array quicksort implementation (several 
> times over, in many different languages).
> 
> Parallel sorting is one of my favorite tricks, and I think it definitely 
> belongs in the standard library.
> 
> --benji

std.algorithm's parameterized swap primitive is motivated in part by 
parallel array manipulation. See the schwartz routines in there for 
examples.

Andrei



More information about the Digitalmars-d mailing list