MCPcopy Create free account
hub / github.com/douchuan/algorithm / sort

Function sort

src/sort/quick.rs:9–19  ·  view source on GitHub ↗

快速排序 C. A. R. Hoare在1960年提出。 它的基本思想是:通过一趟排序将要排序的数据分割成独立的两部分, 其中一部分的所有数据都比另外一部分的所有数据都要小,然后再按 此方法对这两部分数据分别进行快速排序,整个排序过程可以递归进行, 以此达到整个数据变成有序序列

(a: &mut [T])

Source from the content-addressed store, hash-verified

7//! 以此达到整个数据变成有序序列
8
9pub fn sort<T>(a: &mut [T])
10where
11 T: Ord,
12{
13 let len = a.len();
14 if len > 0 {
15 let (l, _, r) = a.select_nth_unstable(len / 2);
16 sort(l);
17 sort(r)
18 }
19}

Callers

nothing calls this directly

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected