SHARE
TWEET

Untitled

a guest Mar 20th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template <typename K, typename V>
  2.  int comparePairs(const void* left, const void* right){
  3.         if((((pair<K,V>*)left)->first) <= (((pair<K,V>*)right)->first))
  4.             return 1;
  5.         else
  6.             return -1;
  7.     }
  8.      
  9. vector<pair<K,V>> items;
  10.      
  11. std::sort(items.begin(), items.end(), comparePairs<K,V>);
  12.      
  13. std::vector<pair<K,V>> items;
  14. std::sort(items.begin(), items.end());
  15.      
  16. template <typename K, typename V>
  17. bool comparePairs(const std::pair<K,V>& lhs, const std::pair<K,V>& rhs)
  18. {
  19.   return lhs.first < rhs.first;
  20. }
  21.      
  22. template< class RandomIt, class Compare >
  23. void sort( RandomIt first, RandomIt last, Compare comp );
  24.      
  25. std::sort(std::begin(container), std::end(container),
  26.           [] (const auto& lhs, const auto& rhs) {
  27.     return lhs.first < rhs.first;
  28. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top