Fixed-Length Array Sorting

Nordlöw via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 12 00:38:15 PDT 2016


On Friday, 8 April 2016 at 07:18:58 UTC, Nordlöw wrote:
> if (less(r[0], r[2])) r.swapAt(0, 2);
> if (less(r[1], r[3])) r.swapAt(1, 3);
> if (less(r[0], r[1])) r.swapAt(0, 1);
> if (less(r[2], r[3])) r.swapAt(2, 3);
>
> right?

Actually, needs a fifth stage

     if (less(r[1], r[2])) r.swapAt(1, 2);

to complete.


More information about the Digitalmars-d mailing list