case problem on sorting direction fixed