Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

STL sort algorithm

$
0
0

The general syntax of the STL sort algorithm is
sort(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 however
sort(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?


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>