Fixed bad input logic in shouldSort()