Comparator is function (or functor) which will be used to compare two values.
For example std::set uses comparator to check if two values are same.
std::map uses comparator to order keys lexicographically from least to largest.
By default it uses std::less function, so it will order from minimum to maximum. If you provide it std::greater instead it will place largest first. Or you can force it to sort by specific field in structure or else... http://stackoverflow.com/questions/12508496/comparators-in-stl