Nice, the one pass is far more elegant than my code below, which is inspired by quicksort...

class Solution:
# @param {integer[]} nums
# @return {void} Do not return anything, modify nums in-place instead.
def sortColors(self, nums):
lo,hi = 0, len(nums)-1
lo2,hi2 = 0, len(nums)-1# pointing at items that are 1
while 1:
while lo<len(nums) and nums[lo]!=2:
if nums[lo]==0:
if lo2<lo and nums[lo2]==1:#if there is a 1 to the left of lo
nums[lo],nums[lo2] = nums[lo2],nums[lo]
while nums[lo2]!=1: lo2+=1
elif nums[lo]==1:
if lo2<len(nums) and nums[lo2]!=1: lo2 = lo
lo+=1
while hi>=0 and nums[hi]!=0:
if nums[hi]==2:
if hi2>hi and nums[hi2]==1:#if there is a 1 to the right of hi
nums[hi],nums[hi2] = nums[hi2],nums[hi]
while nums[hi2]!=1: hi2-=1
elif nums[hi]==1:
if lo2<len(nums) and nums[hi2]!=1: hi2 = hi
hi-=1
if hi>lo and nums[lo]==2 and nums[hi]==0:
nums[lo],nums[hi] = nums[hi],nums[lo]
if hi<=lo: break