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

Function sort

src/sort/floyd.rs:11–24  ·  view source on GitHub ↗
(a: &mut [T])

Source from the content-addressed store, hash-verified

9use crate::common::max_heap;
10
11pub fn sort<T>(a: &mut [T])
12where
13 T: Ord,
14{
15 // 构建最大堆
16 max_heap::build_heap(a);
17
18 let mut i = a.len();
19 while i > 1 {
20 i -= 1;
21 a.swap(0, i);
22 max_heap::heapify(&mut a[0..i], 0);
23 }
24}

Callers

nothing calls this directly

Calls 3

build_heapFunction · 0.50
heapifyFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected