Sorting Algorithm with O(n) complexity