pub fn sort_unstable<T, S>(slice: S) -> Permutation where
    T: Ord,
    S: AsRef<[T]>, 
Expand description

Return the permutation that would sort a given slice, but might not preserve the order of equal elements.

This calculates the permutation that if it were applied to the slice, would put the elements in sorted order.

Examples

let mut vec = vec!['z','w','h','a','s','j'];
let permutation = permutation::sort_unstable(&vec);
let permuted = permutation.apply_slice(&vec);
vec.sort();
assert_eq!(vec, permuted);

You can also use it to sort multiple arrays based on the ordering of one.

let names = vec!["Bob", "Steve", "Jane"];
let salary = vec![10, 5, 15];
let permutation = permutation::sort_unstable(&salary);
let ordered_names = permutation.apply_slice(&names);
let ordered_salaries = permutation.apply_slice(&salary);
assert_eq!(ordered_names, vec!["Steve", "Bob", "Jane"]);
assert_eq!(ordered_salaries, vec![5, 10, 15]);