sort bug fix