Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/QMHTMY/RustBook
/ cbic_sort1
Function
cbic_sort1
code/chapter06/CantBeliveItCanSort.rs:4–12 ·
view source on GitHub ↗
升序排序
(nums: &mut [i32])
Source
from the content-addressed store, hash-verified
2
3
// 升序排序
4
fn cbic_sort1(nums: &mut [i32]) {
5
for i in 0..nums.len() {
6
for j in 0..nums.len() {
7
if nums[i] < nums[j] {
8
nums.swap(i, j);
9
}
10
}
11
}
12
}
13
14
// 升序排序优化版
15
fn cbic_sort2(nums: &mut [i32]) {
Callers
1
main
Function · 0.70
Calls
1
len
Method · 0.45
Tested by
no test coverage detected