I have a string that contains items that I need to extract and sort. Items are those that are preceded by "with", "and", "comprising", and "," followed by their values (enclosed in parenthesis). After items are extracted, I want to re-arrange them from the original format "item description (value)" to the new format "(value) item description". After this, I want to sort the items based on their values, and place all the items inside the <ITEM> tag separated by "#"
For example:
I have a pet project comprising aluminum wire (100), paper (5), and sticks (2).
Desired output:
(2) sticks#(5) paper#(100) aluminum wire
I have attached a representative sample to best illustrate this.
This is a bit complicated so I'm asking anyone for ideas on how best to approach this.