algorithm with O(n^2) complexity for sorting arrays