fix null in sorting bug