fix bug for sorting order