i******e 发帖数: 171 | 1 map index_of_card; // ????
I want to sort the index (int) numerically. For example,
index_of_card.begin()->second will print out the samllest value,
index_of_card.end() ->second will print out the largest value, etc.
Thanks! | c****s 发帖数: 37 | 2 为什么不用
map
【在 i******e 的大作中提到】 : map index_of_card; // ???? : I want to sort the index (int) numerically. For example, : index_of_card.begin()->second will print out the samllest value, : index_of_card.end() ->second will print out the largest value, etc. : Thanks!
| i******e 发帖数: 171 | 3 I need map. For the time being, I have to use both
map and map.
I have thought map in C++ has the similiar way to be manipulated as
hash in Perl, where we can sort by key or by value.
【在 c****s 的大作中提到】 : 为什么不用 : map
| p******f 发帖数: 162 | 4
you can sort c++ map by value if you want, but this would not be the
same sort carried out by the map container. I believe hash sort by
value in perl is the same case, ie. you just pass all the values to a
sort function.
【在 i******e 的大作中提到】 : I need map. For the time being, I have to use both : map and map. : I have thought map in C++ has the similiar way to be manipulated as : hash in Perl, where we can sort by key or by value.
| vi 发帖数: 309 | 5
I don't think this is doable without adding signaficant works.
You can't sort by value; and if you do, that's multi-key,
instead of key-value.
【在 i******e 的大作中提到】 : map index_of_card; // ???? : I want to sort the index (int) numerically. For example, : index_of_card.begin()->second will print out the samllest value, : index_of_card.end() ->second will print out the largest value, etc. : Thanks!
| i******e 发帖数: 171 | 6 oh, I feel good then. I have been afraid that I implemented sth which was al
ready there.
【在 vi 的大作中提到】 : : I don't think this is doable without adding signaficant works. : You can't sort by value; and if you do, that's multi-key, : instead of key-value.
| p******g 发帖数: 347 | 7 just pass a compare function or function object to sort,
your compare function(object) compares
the value instead of the key of your map.
【在 i******e 的大作中提到】 : map index_of_card; // ???? : I want to sort the index (int) numerically. For example, : index_of_card.begin()->second will print out the samllest value, : index_of_card.end() ->second will print out the largest value, etc. : Thanks!
|
|