#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class SomeClass{
public:
SomeClass(size_t value = 0) :
value(value)
{
}
bool operator <(const SomeClass &right)const{
return value < right.value;
}
size_t &data(){
return value;
}
private:
size_t value;
};
int main() {
vector< SomeClass > arr = {3,1,2};
std::sort( begin(arr), end(arr) );
for(auto &elem: arr) {
cout<<elem.data()<<" ";
}
cout<<endl;
std::sort( begin(arr), end(arr), [](auto left, auto right){left=1;return !(left<right);} );
for(auto &elem: arr) {
cout<<elem.data()<<" ";
}
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIApjbGFzcyBTb21lQ2xhc3N7CnB1YmxpYzoKICAgIFNvbWVDbGFzcyhzaXplX3QgdmFsdWUgPSAwKSA6CiAgICAgICAgdmFsdWUodmFsdWUpCiAgICB7CiAgICB9CiAgICBib29sIG9wZXJhdG9yIDwoY29uc3QgU29tZUNsYXNzICZyaWdodCljb25zdHsKICAgICAgICByZXR1cm4gdmFsdWUgPCByaWdodC52YWx1ZTsKICAgIH0KICAgIHNpemVfdCAmZGF0YSgpewogICAgICAgICByZXR1cm4gdmFsdWU7CiAgICB9CiAgICBwcml2YXRlOgogICAgCXNpemVfdCB2YWx1ZTsKCn07CiAKIAppbnQgbWFpbigpIHsKICAgIHZlY3RvcjwgU29tZUNsYXNzID4gYXJyID0gezMsMSwyfTsKICAgIHN0ZDo6c29ydCggYmVnaW4oYXJyKSwgZW5kKGFycikgKTsKICAgIGZvcihhdXRvICZlbGVtOiBhcnIpIHsKICAgICAgIGNvdXQ8PGVsZW0uZGF0YSgpPDwiICI7CiAgICB9CiAgICBjb3V0PDxlbmRsOwogICAgc3RkOjpzb3J0KCBiZWdpbihhcnIpLCBlbmQoYXJyKSwgW10oYXV0byBsZWZ0LCBhdXRvIHJpZ2h0KXtsZWZ0PTE7cmV0dXJuICEobGVmdDxyaWdodCk7fSApOwogICAgZm9yKGF1dG8gJmVsZW06IGFycikgewogICAgICAgY291dDw8ZWxlbS5kYXRhKCk8PCIgIjsKICAgIH0KICAgIHJldHVybiAwOwp9