#include
<
iostream
>
#include < algorithm >
#include < vector >
#include < functional >
using namespace std;
template < typename T >
bool cmp( const T & num1, const T & num2)
{
return num1<num2;
}
int main()
{
vector<int> ivec;
for(int i=0;i<10;i++)
{
ivec.push_back(i/2);
}
ivec.push_back(-10);
for(int i=0;i<ivec.size();i++)
{
cout<<ivec[i]<<" ";
}
sort(ivec.begin(), ivec.end(), cmp<int>);
cout<<"after sort:"<<endl;
for(int i=0;i<ivec.size();i++)
{
cout<<ivec[i]<<" ";
}
}
#include < algorithm >
#include < vector >
#include < functional >
using namespace std;
template < typename T >
bool cmp( const T & num1, const T & num2)
{
return num1<num2;
}
int main()
{
vector<int> ivec;
for(int i=0;i<10;i++)
{
ivec.push_back(i/2);
}
ivec.push_back(-10);
for(int i=0;i<ivec.size();i++)
{
cout<<ivec[i]<<" ";
}
sort(ivec.begin(), ivec.end(), cmp<int>);
cout<<"after sort:"<<endl;
for(int i=0;i<ivec.size();i++)
{
cout<<ivec[i]<<" ";
}
}