Sort an unsorted array