Function afsort::sort_unstable_by [] [src]

pub fn sort_unstable_by<T, F>(vec: &mut [T], to_slice: F) where
    F: Fn(&T) -> &[u8]

Sort method which accepts function to convert elements to &[u8].

#Example

let mut tuples = vec![("b", 2), ("a", 1)];
afsort::sort_unstable_by(&mut tuples, |t: &(&str, _) | t.0.as_bytes());
assert_eq!(tuples, vec![("a", 1), ("b", 2)]);

Footnote: The explicit type annotacion in the closure seems to be needed (even though it should not). See this discussion.