modify the sort function