COUNTING_SORT(A,k)
- fori ← 0 to k do
- C[i] ← 0
- fori ← 0 to n-1 do
- C[A[i]] ← C[A[i]] + 1
- fori ← 1 to k do
- C[i] ← C[i] + C[i-1]
- fori ← 0 to n-1 do
- B[C[A[i]]] ← A[i]
- C[A[i]] ← C[A[i]] -1
RADIX_SORT(A,d)
- for i ← 1 to d do
- use a stable sort to sort A on digit i
BUCKET_SORT(A)
- n ← length(A)
- for i < 1 to n do
- insert A[i] into bin B[⌊n*A[i]⌋]
- for i < 1 to n do
- sort B[i] with insertion sort
- for i < 1 to n do
- A ← A + B[i] // concatenation