1def sort(A):
2
3 # count number of 0's
4 zeros = A.count(0)
5
6 # put 0's at the beginning
7 k = 0
8 while zeros:
9 A[k] = 0
10 zeros = zeros - 1
11 k = k + 1
12
13 # fill all remaining elements by 1
14 for k in range(k, len(A)):
15 A[k] = 1