fix reverse sorting bug