1. |
function CountingSort(A,B,k){ |
2. |
for(var i
= 0; i
< C.length; i++) |
3. |
C[i]
= 0; |
4. |
for(var j
= 0; j
< A.length; j++) |
5. |
C[A[j]]++; |
6. |
for(i
= 1; i
< C.length; i++) |
7. |
C[i]
+= C[i -
1]; |
8. |
for(j
= A.length -
1; j >=
0; j--){ |
9. |
B[C[A[j]]
- 1]
= A[j]; |
10. |
C[A[j]]--; |
11. |
} |
12. |
} |