#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
int main() {
struct Entity {
Entity(std::string name, int order)
: Name{name}
, Order{order}
{}
std::string Name;
int Order;
};
std::vector<Entity> entities;
entities.emplace_back("Test1", 2);
entities.emplace_back("Test2", 3);
entities.emplace_back("Test3", 1);
std::sort(entities.begin(), entities.end(), [](Entity& a, Entity& b) {
return a.Order < b.Order;
});
for(auto& entity : entities) {
std::cout << entity.Name << ": " << entity.Order << "\n";
}
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKaW50IG1haW4oKSB7CglzdHJ1Y3QgRW50aXR5IHsKCQlFbnRpdHkoc3RkOjpzdHJpbmcgbmFtZSwgaW50IG9yZGVyKQoJCTogTmFtZXtuYW1lfQoJCSwgT3JkZXJ7b3JkZXJ9CgkJe30KCQkKICAgIAlzdGQ6OnN0cmluZyBOYW1lOwogICAgCWludCBPcmRlcjsKCX07CglzdGQ6OnZlY3RvcjxFbnRpdHk+IGVudGl0aWVzOwoJZW50aXRpZXMuZW1wbGFjZV9iYWNrKCJUZXN0MSIsIDIpOwoJZW50aXRpZXMuZW1wbGFjZV9iYWNrKCJUZXN0MiIsIDMpOwoJZW50aXRpZXMuZW1wbGFjZV9iYWNrKCJUZXN0MyIsIDEpOwoJCglzdGQ6OnNvcnQoZW50aXRpZXMuYmVnaW4oKSwgZW50aXRpZXMuZW5kKCksIFtdKEVudGl0eSYgYSwgRW50aXR5JiBiKSB7CiAgICAgICAgcmV0dXJuIGEuT3JkZXIgPCBiLk9yZGVyOwogICAgfSk7CiAgICAKICAgIGZvcihhdXRvJiBlbnRpdHkgOiBlbnRpdGllcykgewogICAgCXN0ZDo6Y291dCA8PCBlbnRpdHkuTmFtZSA8PCAiOiAiIDw8IGVudGl0eS5PcmRlciA8PCAiXG4iOwogICAgfQp9