Sort an array in ascending order filled with 0's and 1's. Traverse the array once ex. O(n).
Iterate from both ends of the array.
Keep two pointers, one pointing to the beginning of the array and another at the end (n - 1) named left and right respectively.

While left < right
1. Increment left till you reach a 1
2. Decrement right till you reach a 0
3. Swap the two digits or just reassign left to 0 and right to 1

Thoughts or alternate solution? Let us know in the comments below!