fix incorrect sorting order