operator<, , std::sort.
#include <algorithm>
class Foo
{
public:
int num;
int other;
};
bool operator<(const Foo& x, const Foo& y)
{
return x.num < y.num;
}
int main()
{
Foo bar[10] = {{1, 5}, {9, 2}, {3, 0}, {5, 7}, {1, 3}, {6, 4}, {10, 8}, {0, 9}, {6, 2}, {3, 5}};
std::sort(bar + 0, bar + 10);
}
, Foo, , .
operator< Foo, C ++ std::sort.