Completed
Push — master ( f90dfb...c5f758 )
by Xianshun
01:33
created

LSD.sort()   B

Complexity

Conditions 6

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
c 1
b 0
f 0
dl 0
loc 20
rs 8
1
class LSD(object):
2
    R = 256
3
    @staticmethod
4
    def sort(a):
5
        W = len(a[0])
6
        aux = [None] * len(a)
7
8
        for d in range(W-1, -1, -1):
9
            count = [0] * (LSD.R+1)
10
11
            for i in range(len(a)):
12
                count[ord(a[i][d])+1] += 1
13
14
            for r in range(0, LSD.R):
15
                count[r+1] += count[r]
16
17
            for i in range(len(a)):
18
                aux[count[ord(a[i][d])]] = a[i]
19
                count[ord(a[i][d])] += 1
20
21
            for i in range(len(a)):
22
                a[i] = aux[i]
23