Sorting according to a primary and secondary criterion
bearophile
bearophileHUGS at lycos.com
Wed Jul 17 05:07:46 PDT 2013
Joseph Rushton Wakeling:
> Is there a standard, accepted approach for this kind of sort
> with primary/secondary criterion?
There are various ways to do it. One way is to use a stable sort
and sort the data two or more times.
Another way is to use something like this, but this needs some
memory:
idx.schwartzSort!(i => tuple(arr1[i], arr2[i]));
But often the most efficient way is to use sort() with a
comparison function that takes in account all your sorting
criteria.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list