This template argument appears redundant.

How about modifying `sort_by_first`'s definition like this:
```
struct sort_by_first {
  template<class T, class S>
  bool operator() const (
      const std::pair<T, S>& p1,
      const std::pair<T, S>& p2) const {
    return p1.first < p2.first;
  }
};
```
and use `sort_by_first()`?