Index into lexicographically sorted list of permutations, or find indexes of permutations without constructing the sorted lists.
Worthy of note is the slightly odd monad, Œ?, which will find the shortest possible permutation of items [1,length] that would have such an index, but is useful since that range is (length-1)!+1 to length! inclusive. If one needs to find lower entries use the dyad with an integer (or range) instead. As an example 24Œ? will return the 24th permutation of four items [4,3,2,1], if you actually want the 24th permutation of more items do something like 24œ?7 to get [1,2,3,7,6,5,4].
Index into lexicographically sorted list of permutations, or find indexes of permutations without constructing the sorted lists. Worthy of note is the slightly odd monad,
Œ?
, which will find the shortest possible permutation of items [1,length] that would have such an index, but is useful since that range is (length-1)!+1 to length! inclusive. If one needs to find lower entries use the dyad with an integer (or range) instead. As an example24Œ?
will return the 24th permutation of four items[4,3,2,1]
, if you actually want the 24th permutation of more items do something like24œ?7
to get[1,2,3,7,6,5,4]
.