recursive sort