recursively sort an array in ascending order