Let's say we have an array a = [5, 2, 3, 8, 4, 1, 9]
I want to choose a few elements (without replacement) so that the relative order of the chosen elements will be the same as in an input array.
Using the random.choice with shuffle=False doesn't seem to do this.
a = [5, 2, 3, 8, 4, 1, 9]
rng = np.random.default_rng(42)
rng.choice(a, 4, replace=False, shuffle=False)
Output:
array([9, 5, 1, 8])
I want to see:
array([5, 8, 1, 9])
What's the simplest way to achieve this result?