第一种方法:

#include "stdafx.h"
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
struct AssessTypeInfo
{
unsigned int m_uiType; //类型ID
char m_szName[64];   //类型名称
unsigned int m_uiTotal; //总分数

bool operator <   (const AssessTypeInfo& rhs )   const //升序排序时必须写的函数
{
return m_uiType < rhs.m_uiType;
}
bool operator >   (const AssessTypeInfo& rhs )   const //降序排序时必须写的函数
{
return m_uiType > rhs.m_uiType;
}
}
int main()
{
vector<AssessTypeInfo > ctn ;

AssessTypeInfo a1;
a1.m_uiType=1;
AssessTypeInfo   a2;
a2.m_uiType=2;

AssessTypeInfo   a3;
a3.m_uiType=3;

ctn.push_back(a1);
ctn.push_back(a2);
ctn.push_back(a3);
//升序排序
sort(ctn.begin(), ctn.end(),less<AssessTypeInfo>()) ; //或者sort(ctn.begin(), ctn.end())   默认情况为升序

for ( int   i=0; i<3; i++ )
printf("%d\n",ctn[i].m_uiType);

//降序排序
sort(ctn.begin(), ctn.end(),greater<AssessTypeInfo>()) ;

for ( int   i=0; i<3; i++ )
printf("%d\n",ctn[i].m_uiType);


return 0   ;
}
以上方法就可以实现升序排序,输出结果为 1   2 3  
降序排序结果3   2   1。
方法2 :   不修改结构体或类的定义部分,我们用函数对象来实现:
#include "stdafx.h"
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
struct AssessTypeInfo
{
unsigned int m_uiType; //类型ID
char m_szName[64];   //类型名称
unsigned int m_uiTotal; //总分数
};

bool lessmark(const AssessTypeInfo& s1,const AssessTypeInfo& s2)
{
return s1.m_uiType < s2.m_uiType;
}
bool greatermark(const AssessTypeInfo& s1,const AssessTypeInfo& s2)
{
return s1.m_uiType > s2.m_uiType;
}
int main()
{
vector<AssessTypeInfo > ctn ;

AssessTypeInfo a1;
a1.m_uiType=1;
AssessTypeInfo   a2;
a2.m_uiType=2;

AssessTypeInfo   a3;
a3.m_uiType=3;

ctn.push_back(a1);
ctn.push_back(a2);
ctn.push_back(a3);

sort(ctn.begin(), ctn.end(),lessmark) ; //升序排序lessmark 需为全局函数


for ( int   i=0; i<3; i++ )
printf("%d\n",ctn[i].m_uiType);

sort(ctn.begin(), ctn.end(),greatermark) ; //降序排序


return 0   ;
}