Correctly implementing 'partition'.