#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

struct Person {
    std::string name;
    int age;
};

// Compare using std::string's less-than operator.
bool operator< (const Person& lhs, const Person& rhs) {
    return lhs.name < rhs.name;
}
 
int main() {
    // Create vector of Person objects and initialize with some random names.
    std::vector<Person> crew { {"Bob", 45}, {"Steve", 25}, {"Andy", 30} };

    // Sort vector using < operator.
    std::sort(begin(crew), end(crew));

    // Output all elements in vector.
    for(const auto& p : crew) {
        std::cout << p.name << " is " << p.age << " years old" << std::endl;
    }
}