fixed an error in sort methods