Fix bugs in ThreeWayQuickSorter