10. 计数排序
约 57 字
预计阅读 1 分钟
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import random
def func(li):
temp = [0 for _ in range(max(li)+1)]
for i in li:
temp[i] += 1
li.clear()
for index, value in enumerate(temp):
for j in range(value):
li.append(index)
print(li)
a = [random.randint(0, 100) for _ in range(100)]
func(a)
|