std::sort 要求的是 random_access_iterator, vector 刚好合适。
既然是 C++,struct 也可以重载 operator< 的。或者另外一个方法:
自己写一个比较函数对象
A binary predicate takes two arguments and returns true when satisfied and false when not satisfied.
例如:
struct PcbCompair
{
bool operator()(const pcb& a, const pcb& b)
{
return a.needtime < b.needtime;
}
};
没有调试,详见 MSDN 2003 APRIL
ms-help://MS.MSDNQTR.2003APR.1033/vcstdlib/html/vclrfAlgorithmSort.htm