【发布时间】:2016-04-16 01:53:21
【问题描述】:
我正在尝试以下代码。我正在尝试按升序或降序大小以及从 z-a (三种不同的排序)对其进行排序。我不知道如何将它存储在向量中,更不用说对其进行排序了。感谢您的帮助!
struct countSize {
int count;
uintmax_t size;
void sortMap(map<string, countSize> &extCount)
{
// Copy
vector<string, countSize> v(extCount.begin(), extCount.end());
// Sort the vector according to either file size or desc alphabetically
//print
}
int main()
{
map<string, countSize> mp;
mp["hello"] = { 1, 200 };
mp["Ace"] = { 5, 600 };
mp["hi"] = { 3, 300 };
mp["br"] = { 2, 100 };
sortMap(mp);
}
【问题讨论】:
标签: sorting dictionary vector struct