The general syntax of the STL sort algorithm issort(myvector.begin(),myvector.end()); //used for sorting an array of integers in the ascending order
The code for sorting an array of integers in the descending order is howeversort(myvector.rbegin(),myvector.rend());
I was wondering if we could just use sort(myvector.end(),myvector.begin());
as they are already defined. Is it legal to do so or will it generate some kind of error? Why create new methods when we already have a method existing to do the exact same thing?
↧
STL sort algorithm
↧