Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(->> (map vector a b)
(sort-by first)
(apply (partial mapv vector)))
record QuickSort<T extends Comparable<T>>(List<T> a, List<?> b) {
void sort(int x, int y) {
if (x >= y || x < 0) return;
int p = f(x, y);
sort(x, p - 1);
sort(p + 1, y);
}
int f(int x, int y) {
T t = a.get(y);
int i, j = i = x;
do if (a.get(j).compareTo(t) < 1) {
swap(a, i, j);
swap(b, i++, j);
} while (++j < y);
swap(a, i, y);
swap(b, i, y);
return i;
}
}
type
TPairedList = class(TStringList)
private
FBuddy: TStrings;
protected
procedure ExchangeItems(Id1, Id2: Integer); override;
public
procedure Sort(Buddy: TStrings); overload;
end;
procedure TPairedList.ExchangeItems(Id1, Id2: Integer);
begin
inherited Exchange(Id1, Id2);
if Assigned(FBuddy) then
FBuddy.Exchange(Id1, Id2);
end;
procedure TPairedList.Sort(Buddy: TStrings);
begin
FBuddy := Buddy;
Sort;
end;
begin
...
a.sort(b);
end.
a, b = zip(*sorted(zip(a, b)))
a, b = a.zip(b).sort.transpose
let mut tmp: Vec<_> = a.iter().zip(b).collect();
tmp.as_mut_slice().sort_by_key(|(&x, _y)| x);
let (aa, bb): (Vec<i32>, Vec<i32>) = tmp.into_iter().unzip();