2 ms·
D has std.zip: https://dlang.org/phobos/std_range.html#zip https://dlang.org/phobos/std_range.html#zip Sorting two arrays in parallel: import std.algorit
by WalterBright 4y ago
D has std.zip:
https://dlang.org/phobos/std_range.html#zip https://dlang.org/phobos/std_range.html#zip
Sorting two arrays in parallel:
import std.algorithm.sorting : sort;
int[] a = [ 1, 2, 3 ];
string[] b = [ "a", "c", "b" ];
zip(a, b).sort!((t1, t2) => t1[0] > t2[0]);
writeln(a); // [3, 2, 1]
// b is sorted according to a's sorting
writeln(b); // ["b", "c", "a"]