functor
struct S { int x, y; }; struct Comparator { bool operator() (const S& s1, const S& s2) { return s1.x < s2.x; } }; int main() { S arr[100]; std::sort(arr, arr+100, Comparator()); }