Welcome!
Asking for help from a respected Abrasheva to the decision of such tasks:
In the process of writing a simple interpreter for mathematical expressions (so far, even without parentheses, the banal expressions such as
5+15*2/10+2^3) just 4 fun, as they say, faced with the problem...
I get the array of operations in terms of position=>operation, which for the above example would be:
array( 1 => '+', 4 => '*', 6 => '/' 9 => '+', 11 => '^', )
I also have an array of priorities of operations of the form
array( '+' => 1, '-' => 1, '*' => 2, '/' => 2, '^' => 3, )
Now to sort transactions by priority, but that's something inhibit all morning, can't think of the...
In the end we need to (for this example) the following array:
array( 11 => '^', 4 => '*', 6 => '/', 1 => '+', 9 => '+', )
I would be grateful for assistance in the form of an algorithm.