Sorting algorithms with O(N^2)