Sort algorithm
Oskar Linde
oskar.lindeREM at OVEgmail.com
Wed Jan 24 07:47:25 PST 2007
Alain wrote:
> Hi,
>
> I have a question related to the sort function.
> Does anyone know which algorithm is used in the built-in array sort function.
> I needed to sort 256 integers. By using a radix sort, i got 30 usec on my laptop. But using the built-in sort, i get 20 usec.
> I thought the radix sort was pretty efficient.
> Any idea?
The built in sort uses quick sort, falling back on insertion sort when
the slices get small enough. Which sorting algorithm is fastest depends
very much on the problem. How is your data distributed for instance? The
implementation is also very important. A template sorting function can
easily become 50 % faster than the D built in sort when operating on
primitive data types.
/Oskar
More information about the Digitalmars-d
mailing list