Test sort order and fix the actualorder returned in the input selection algorithm