'How to force set in c++ to store values in descending order?
I have been stuck on an algorithm that requires unique values sorted in descending order. Since the need is unique, I thought set is the best data structure to be used here, but I guess set by default stores the value in non-decreasing order, how do I make it store in non-increasing order?
Other than the fact that I can let it store in ascending order and then reverse the set, is there any other modification that I can do?
Solution 1:[1]
The order of the set can be changed by changing/defining operator < for the objects stored in your set.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | stegzzz |