I know there is an accepted answer, but you can also use decltype in C ++ 11 for this, it looks a little dirty ...
stable_sort(X.rbegin(), X.rend(), [](decltype(*X.cbegin()) lhs, decltype(lhs) rhs) { return lhs.first < rhs.first; });
Use cbegin() here when you get the const const value_type in the container.
Nim May 6 '15 at 9:36 a.m. 2015-06-06 09:36
source share