BUG: minor, sorting logic