Is that supposed to be a joke?
How can it get any easier than calling a function?
1 2 3 4 5 6 7 8 9
#include <iostream>
#include <algorithm>
usingnamespace std;
int main()
{
int myints[] = {32,71,12,45,26,80,53,33};
sort(myints,myints+8);
}
There, it's sorted.
The only way to make it any easier is to store your values in a std::set. Then you'll have to do literally nothing to get your values sorted as std::set already takes care of that.
The C++ reference pages are an invaluable resource, but...to those unaccustomed to the formal formatting of them, they can make things look a lot more complicated than they really are.
As Athar indicated above, the sort() function really is just as simple as including <algorithm>, and calling sort with a beginning and ending location.
That would be if you made your own sort function and had to iterate over all the elements to be sorted. Still... I don't see how a for loop makes things complicated.
There is it. And it actually works. thanks!! But I thought it was harder then this as my friends said.
I dont understand sort (array, array +5);
what does +5 part do?