I was trying to make a map sort by value using a custom comparator but I couldn\'t figure out why I kept getting the error of \"no matching call to compareByVal\"
Here\'
If you want to sort a std::map by its value, then you are using the wrong container. std::map is sorted by the keys by definition.
std::map
You can wrap key and value:
struct foo { int key; int value; };
and then use a std::set that uses a comparator that only compares foo::value.
std::set
foo::value