Fixed sorting bug