【发布时间】:2014-11-17 16:30:41
【问题描述】:
如何按字母顺序排序,然后按班级中的int 变量排序?如何组合它们,如果counter 相同,它将按字母顺序返回?
// sort pages by its popularity
bool popularity(const Page &a, const Page &b) {
return a.counter > b.counter;
}
// alphabetical sort
bool alphaSort(const Page &a, const Page &b) {
return a.name < b.name;
}
// Combination?
sort(.begin(), .end(), ??)
【问题讨论】:
-
您的意思是要按受欢迎程度对页面进行排序,然后按字母顺序对受欢迎程度相同的页面进行排序?
-
是的,正是我想要实现的。这两个功能都有效,只是不知道如何将它们组合在一起。