permute<T> function
Returns a permutation of source using the specified integer keys.
Implementation
// DIVERGES(d3-array): adapt-array-typed-api, split typed List permute,
// out-of-bounds permuteNullable, and Map-keyed permuteMap.
List<T> permute<T>(List<T> source, Iterable<int> keys) {
if (keys is List<int>) {
final n = keys.length;
return List<T>.generate(n, (i) => source[keys[i]]);
}
return <T>[for (final key in keys) source[key]];
}