For all the permutations of a list, I want to print only those permutations in which the value at a particular index is greater than the values at previous indexes. Such an index would be called a "great index"
ex: If the list is [1,2,3], its permutations are
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)
I would like to print only such permutations in which there are only n "great indices". Let's say n=2, then the output would be:
[1,3,2],[2,1,3] and [2,3,1]
In [1,3,2], indices 0 and 1 are great indices because 1(at index 0) does not have any previous elements and 3(at index 1) is greater than its previous element i.e 1. 2(at index 2) is not a "great index" because it is not greater than its previous element 3.
Similarly,
In [2,1,3], indices 0 and 2 are great indices.
In [2,3,1], indices 0 and 1 are great indices.
I'm using the permutations library in Python to generate the permutations. A simple, easy to understand solution would be appreciated.