Declare three counters temp0, temp1, temp2;
Now parse through the list and update these counters;
After the first parsing we have number of 0s,1s and 2s in the list.
Now from starting with head node of the list fill it first with 0s and then 1s and then 2s
I hope it is correct