[Solved] C++ Own comparison in std::list

[ad_1]

list::sort requires a predicate function-object.

You can try:

std::list<person> people;

// Add some people...

people.sort([](const person &left, const person &right)
{
    return left.name < right.name;
});

See also:

Sorting a list of a custom type

1

[ad_2]

solved C++ Own comparison in std::list