sort

struct node
{
    char str[22];
    int num;
    int score;
}stu[N];

bool cmp(const node &a, const node &b)
{
    if(a.score == b.score)
        return strcmp(a.str, b.str) < 0 ? 1 : 0; //按字典序升序
    else
        return a.score > b.score;
}

sort(stu , stu + N, cmp);
原文地址:https://www.cnblogs.com/wwjyt/p/3178672.html