fixed error in sort