Code Golf
Mathgeek
Now to start thinking laterally!

For an array of N distinct numbers in increasing order, there are N! ways to permute that array. Those permuted arrays can then also be sorted, prioritizing whichever array has the smallest element in the first position, then breaking ties with the second position, etc.

The input is an array and a number M with 0 <= M < N! , and the output should be, if one sorted all N! permutations of the original array, the Mth element of that list of permutations. So, M = 0 would give your original sorted array, and M=N!-1 would be the array in reverse.

| Input | Output |
|-------|--------|
|[1, 2, 3, 4], 5|[1, 4, 3, 2]|
|[1, 4, 7], 2|[4, 1, 7]|
|[3, 4, 6, 9, 10], 114|[10, 9, 3, 4, 6]|
|[1, 2, 3], 0|[1, 2, 3]|
Top Answer J
Bubbler
# [J], 2 bytes

    A.

[Try it online!][TIO-k663bb82]

[J]: http://jsoftware.com/
[TIO-k663bb82]: https://tio.run/##PY07C4NAEITr218xpBFhc@w9VBRShEAgEAikPWwtUkgK/f2X9TAWy843s49PPtlqwmVABYZg0Dpb3N7Pe77aXOcGExw8AiL5oiM6ci6qVg8tejgh@Y8RlSP0mL/rYl7roo2SY3hGYMSR0ZiNY2E/0g6dJt4kVW4DSqHYLaNXSzTVp7opxdjD8TituZgDqP4B "J – Try It Online"

Sorry for the boring answer, but this is a bulit-in function which computes the `n`th permutation of the given array in the increasing order.

```
    5 A. 1 2 3 4
1 4 3 2

    114 A. 3 4 6 9 10
10 9 3 4 6
```

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.