Add sorting logic for listing handler.