fixed an issue in sort