Modify sort function.