I have six characters: (,),[,],{,}. They are stored lexicographically: '(' < ')' < '[' < ']' < '{' < '}'. So I can store all balanced parenthesis sequences of length $n$ lexicographically and each sequence will have unique number $1 \dots catalan(n)*3^n$. Than I want to get sequence by its number.
Problem: If I have another order, for example '}' < '[' < ')' < '(' < '{' < ']', then all balanced parenthesis sequences again are stored in lexicographical order, but the same sequences will have different numbers, according to these two orders. If I'm given a number of a sequence in second order, can I efficiently recalculate it to the number of the same sequence but in the first order? The main problem is that I don't know the sequence which corresponds to given number in second order. (I wish to find it)
Example: First order: '(' < ')' < '[' < ']' < '{' < '}'
Second order: '}' < '[' < ')' < '(' < '{' < ']'
I get number 1 for sequences with 1 pair of parthenses, the corresponding sequence is [] in the second order. I want to calculate number of [] in first order --- it is 2.
But I don't know how sequence for number 1 in seconds order looks like. I want just by number get the number of the same sequence in first "canonical" order.