fix the sorting of results