vector pair sort

bool strict_weak_ordering(const std::pair a, const std::pair   b)      
{      
    return a.first < b.first;      
}      
       
int main()      
{      
  using namespace std;      
       
  vector > vec;      
       
   vec.push_back(make_pair(5, "hello"));      
   vec.push_back(make_pair(4, "hell"));      
   vec.push_back(make_pair(6, "hello,"));      
       
   sort(vec.begin(), vec.end(), strict_weak_ordering);      
       
   vector >::iterator it = vec.begin(), end = vec.end();      
   
   for(; it != end; ++it)      
     cout<second<

你可能感兴趣的:(数学)