Others have already shown C++98/03 solutions. In C++11, you might want to use a lambda for your comparison instead:
// ascending age:
std::sort(people.begin(), people.end(),
[](person const &a, person const &b) { return a.age < b.age; });
// descending age:
std::sort(people.begin(), people.end(),
[](person const &a, person const &b) { return b.age < a.age; });
And, in case it should happen to arise:
// ascending name:
std::sort(people.begin(), people.end(),
[](person const &a, person const &b) { return a.name < b.name; });
// descending name:
std::sort(people.begin(), people.end(),
[](person const &a, person const &b) { return b.name < a.name; });
IMO, Information
is too generic a name, so I've changed it to person
. Contrariwise, listOfPeople
puts too much emphasis on the form rather than the content (and, worse, it's just plain wrong, since you really have a vector of people, not a list at all). IMO, in programming, it's generally better to use list
only to refer to a linked list, not to linear data structures in general.