* @throws IllegalArgumentException in case {@code secondary} is shorter than the {@code primary}
* */
public static void sortPairs(final WritableIntList primary, final WritableIntList secondary) throws IllegalArgumentException {
if (primary.size() > secondary.size()) throw new IllegalArgumentException("secondary is shorter than primary: " +
primary.size() + " > " + secondary.size());
IntegersUtils.quicksort(primary.size(), new IntIntToInt() {
@Override
public int invoke(int i, int j) {
int comp = IntCollections.compare(primary.get(i), primary.get(j));
if (comp == 0) comp = IntCollections.compare(secondary.get(i), secondary.get(j));
return comp;