R, a programming language used for Statistics and Data Analysis, has the function order, which returns a list with the indices needed to sort the original vector(∗).
For example:
my_list = [1, 3, 3, 9, 8]
# Ordered would be: [0, 1, 2, 4, 3]
In plain words, order tells you what elements to look at in your original vector to sort it. The list my_list[0] + my_list[1] + my_list[2] + my_list[4] + my_list[3] is equivalent to sorted(my_list).
If two or more elements have the same order, their original order is preserved. Here, [0, 1, 2, 4, 3] and [0, 2, 1, 4, 3] would both sort the vector, but only the first one preserves the original order for the two 3s.
Implement the function order() so that it works the same way it does in R.
order([9, 1, 4, 5, 4]) ➞ [1, 2, 4, 3, 0]
order(["z", "c", "f", "b", "c"]) ➞ [3, 1, 4, 2, 0]
order(["order", "my", "words"]) ➞ [1, 0, 2]