Sorting methods
Sort
of Sort for &'self mut [T] where <'self, T: Copy + Ord + Eq>
merge_sort
- Merge sortquick_sort
- Quicksortquick_sort3
- Fancy quicksorttim_sort
Sort
qsort
fn qsort(self)
Sort
for &'self mut [T]
where <'self, T: Copy + Ord + Eq>
qsort
fn qsort(self)
merge_sort
fn merge_sort<T: Copy>(v: &[T], le: Le<T>) -> ~[T]
Merge sort. Returns a new vector containing the sorted list.
Has worst case O(n log n) performance, best case O(n), but is not space efficient. This is a stable sort.
quick_sort
fn quick_sort<T>(arr: &mut [T], compare_func: Le<T>)
Quicksort. Sorts a mut vector in place.
Has worst case O(n^2) performance, average case O(n log n). This is an unstable sort.
quick_sort3
fn quick_sort3<T: Copy + Ord + Eq>(arr: &mut [T])
Fancy quicksort. Sorts a mut vector in place.
Based on algorithm presented by ~[Sedgewick and Bentley] (http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf). According to these slides this is the algorithm of choice for 'randomly ordered keys, abstract compare' & 'small number of key values'.
This is an unstable sort.
tim_sort
fn tim_sort<T: Copy + Ord>(array: &mut [T])