Maybe you can avoid swaps if you actually return zeros in your sort function though?