如何对其中包含地图的列表进行排序
how to sort a list containing maps in it
我正在尝试按照其第二浮标编号(在pair<float,float>
中(对地图进行排序:
list<map<string, pair<float, float>>>
任何人都可以帮助我...
我已经尝试了此操作:
void my_sort(list<map<string, pair<float, float>>> ans)
{
for (int i = 1; i < ans.size(); i++)
{
for (list<map<string, pair<float, float>>>::iterator j = ans.begin(); j < ans.end; j++)
{
if(j->)
}
}
}
任何人都可以帮助我...
您不太清楚如何比较两个地图,但是一旦您弄清楚您可以使用少于操作员进行自定义排序执行自定义排序,例如:
struct less_than_key
{
inline bool operator() (map<string, pair<float, float>> &map1, map<string, pair<float, float>> &map2)
{
// Here you need to figure out what makes one map 'less than' the other
// If if a specific key's value.second is < the same in the other map, for example.
return map1IsLessThanMap2;
}
};
std::sort(yourList.begin(), yourList.end(), less_than_key());
相关文章:
- 试图在c++中对数字列表进行排序
- 在STL - C++中按成绩对学生列表进行排序?
- 使用列表 STL 递归进行插入排序
- 列表 iter 不取消引用 使用列表进行插入排序
- 如何在 c++ 中根据第二个元素按降序对列表进行排序
- 为什么在排序链表上的这种合并实现总是将两个列表都设置为 NULL,而只有一个应该设置一个列表?
- 如何按键对 std::对列表进行排序?
- 如何通过保持第一个插入的位置来对列表中插入的其余元素进行排序?
- 如何使用cpp编写选择排序算法以降序对元素列表进行排序?
- 使用自定义比较函数在类内进行列表排序
- 列表::排序更改值C
- 对于列表排序,有没有办法使用相同的参数让多个运算符重载?
- 在 c++ 中将数字从列表排序到数组中的气泡排序问题
- 运算符<用于列表排序
- C++列表排序功能
- C++ STL 算法(列表排序)OpenMP/多线程实现
- 列表排序不正确
- 列表排序和结构体向量排序之间的性能差距.c++
- 对抽象数据类型的stl::列表排序
- C++std列表排序使用自定义比较器,该比较器依赖于对象实例的成员变量