方法一:在结构体中重载< 、>运算符,调用STL的sort()函数
#include "stdafx.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
class MYSTRUCT
{
public:
int id;
int nums;
vector<int> vec;
MYSTRUCT()
{
id=numeric_limits<int>::max();
nums=0;
vec.resize(0);
}
//重载==
bool operator==( const MYSTRUCT& objstruct) const
{
return objstruct.id==id;
}
//重载<
bool operator<(const MYSTRUCT& objstruct) const
{