how to declare comparator for set of pair

#include <iostream>
#include <set>
using namespace std;

bool comparePairs(const pair<int, int>& p1, const pair<int, int>& p2) {
    if (p1.first != p2.first) {
        return p1.first < p2.first;
    }
    return p1.second < p2.second;
}

int main() {
    set<pair<int, int>, decltype(&comparePairs)> pairSet(&comparePairs);

    pairSet.insert({1, 2});
    pairSet.insert({2, 1});
    pairSet.insert({1, 3});

    for (const auto& p : pairSet) {
        cout << "(" << p.first << ", " << p.second << ") ";
    }
    cout << endl;

    return 0;
}