Adding Radix Sort into Phobos

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 27 02:14:25 PDT 2015


On 04/27/2015 09:52 AM, "Per =?UTF-8?B?Tm9yZGzDtnci?=
<per.nordlow at gmail.com>" wrote:
> Does someone have any answers to these questions or should I wait until
> the prel. pull request is done?:
> 
> •Figure out a way to template-parameterize  radixSortImpl  to make it
> work on aggregate element types when the comparison function can be
> expressed as an data-member-accessor of the aggregate. For example if
> ElementType is a  struct S { int x, y; }  and comparison function "a.x <
> b.x".

I think an alias transform function that defaults to identity makes most
sense.
That's a bit similar to
http://dlang.org/phobos/std_algorithm_sorting.html#schwartzSort.
And it doesn't look like you support custom predicates.

> •If possible implement a generic sorting algorithm that automatically
> selects the best suitable in-Place sorting algorithm based on types of
> the input parameters (range and comparsion/accessor function). This
> currently means  isIntegral,  float,  double, and as above mentioned
> aggregates sorted on a member or combination of members whose bijection
> can fit into 8, 16, 32 or 64 bits.

That's a tough problem => treat it separately.


More information about the Digitalmars-d mailing list