MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / radixSortLSD

Function radixSortLSD

RadixSort.py:8–29  ·  view source on GitHub ↗
(alist)

Source from the content-addressed store, hash-verified

6
7# 最低位优先法
8def radixSortLSD(alist):
9 if len(alist) == 0:
10 return
11 if len(alist) == 1:
12 return alist
13 tempList = alist
14 maxNum = max(alist)
15 radix = 10
16 while maxNum * 10 > radix:
17 newArr = [[], [], [], [], [], [], [], [], [], []]
18 for n1 in tempList:
19 testnum = n1 % radix
20 testnum = testnum // (radix / 10)
21 for n2 in range(10):
22 if testnum == n2:
23 newArr[n2].append(n1)
24 tempList = []
25 for i in range(len(newArr)):
26 for j in range(len(newArr[i])):
27 tempList.append(newArr[i][j])
28 radix *= 10
29 return tempList
30
31
32

Callers 1

RadixSort.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected