Function merge_sort

Source
pub fn merge_sort<T: PartialEq + PartialOrd + Copy>(arr: &mut [T])
Expand description

Sort an array using merge sort

§Parameters

  • arr: A vector to sort in-place

§Type parameters

  • T: A type that can be checked for equality and ordering e.g. a i32, a u8, or a f32.

§Undefined Behavior

Does not work with String vectors.

§Examples

use algorithmplus::sort::merge_sort;
 
let mut ls = vec![3, 2, 1];
merge_sort(&mut ls);
 
assert_eq!(ls, [1, 2, 3]);