changed the sort function.