just count the numbers of color and print them out.

```
void sortColors(int A[], int n) {
int num_red=0;
int num_white=0;
int i;
for(i=0;i<n;i++)
{
if(A[i]==0)
num_red++;
else if(A[i]==1)
num_white++;
}
for(i=0;i<n;i++)
{
if(i<num_red)
A[i]=0;
else if (i>=num_red && i<(num_red+num_white))
A[i]=1;
else
A[i]=2;
}
}
```