fix bug of sorting