fixed bugs in sorting algorithms