given the variable of different nested containers.
std::pair<NonTerminal, std::vector<std::vector<Symbol>>> productions;
How can I order the pair-entries ascending from 0 to ..., such that I can maybe make use of an ::iterator
- if even possible/necessary (better way of organization?)
I thought of nesting the above in another pair like this:
std::pair<int, std::pair<NonTerminal, std::vector<std::vector<Symbol>>>> productions;
How could I then in ascending order iterate over my internal representation of grammatical productions (where the NonTerminal
of the inner std::pair
is the right-hand-side of the production, and the std::vector
the right-hand-side.)
Thanks !
EDIT:
What I want is give a total order to the productions
std::pair<NonTerminal, std::vector<std::vector<Symbol>>> productions;
and iterate over them in ascending order.
@ jarod42: Here (Ruby - sort array of objects by attribute in descending order) is a good example how to order by any attribute in ascending/descending order