Updated the sort methods to do less swaps