简单的计数排序
public class Solution {
public void sortColors(int[] A) {
int red = 0, blue = 0, white = 0;
for(int i = 0; i < A.length; ++i){
if(A[i] == 0)red++;
else if(A[i] == 1) white ++;
else blue ++;
}
for(int i = 0; i < red; ++i){
A[i] = 0;
}
for(int i = red; i < red + white; ++i)
A[i] = 1;
for(int i = red +white; i < A.length; ++i)
A[i] = 2;
}
}