or example, if you are given "abcd", the lexicographical permutations would be:
abcd
abdc
acbd
acdb
adbc
adcb
bacd
badc
bcad
bcda
bdac
bdca
cabd
cadb
cbad
cbda
cdab
cdba
dabc
dacb
dbac
dbca
dcab
dcba
I understand intuitively how it is meant to be sorted and if you gave me any set of letters or numbers I could work it out for how they should be sorted, but not mathematically of how you would get from the one step to the next. For example: What is the mathematical process that takes you from abdc to acbd?