Sorting algorithms in C++