I need to sort std::pair, the second element are different struct, ideally i would like to have a single elegant function but i could also do overloaded function, unfortunately even with overloaded functions its not compiling because of : <unresolved overloaded function type>
typedef struct{
int x, y;
} myStruct;
template <typename S> static bool comp(std::pair<int, S> pair1, std::pair<int, S> pair2){
auto val1 = std::get<int>(pair1);
auto val2 = std::get<int>(pair2);
return val1 < val2;
}
int main(){
myStruct test;
std::vector<std::pair<int, myStruct>> v {{9,test}, {2,test}, {4,test}, {3,test}, {1,test}};
std::sort(v.begin(), v.end(), comp);
}