I have such structure with ids and their count:
product[38] = 10;
product[22] = 7;
product[39] = 18;
I need to use some structure for it. But not sure what should serve better (map, unordered_map, set, vector).
I was trying to use:
map<int, int> product;
But not sure is it the best choice. The only thing that I should do with it – sorting.
As a result I need:
product[39] = 18;
product[38] = 10;
product[22] = 7;
UPD: Sort by value.
You may want to make a struct or std::pair and sore them in std::vector
sort by value: