C++ selection sort implementation