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

Reply via email to