V
V
Valery Demidov2015-10-14 15:24:51
C++ / C#
Valery Demidov, 2015-10-14 15:24:51

How to sort map by value?

You need to sort the map, tell me how to do it in the most convenient way. For Google suggests very abstruse things or very simple ones, the inhabitants of the toaster can share the golden mean (worked out hacks).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ruchkin, 2015-10-14
@Fraideron

The question does not make sense, since map stores sorted by key (a custom comparator is possible) and does not allow changing this order. So in terms of value, no way. Take out pairs from there, and sort them. What problem is actually being solved?

N
newcode, 2015-10-14
@newcode

But isn't map a "sorted associative container"? if necessary, from larger to smaller, go from the end, if from small to larger, go from the beginning

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question