updated the sorting behavior