Permutes the array according to the given indices.
List<T> permute<T>(List<T> array, List<int> indices) { return indices.map((i) => array[i]).toList(); }