np.unique not preserving the original array order when finding unique elements in NumPy
I'm relatively new to this, so bear with me. I'm working with an scenario where using `np.unique` on a NumPy array is not preserving the order of elements as they appear in the original array. For example, when I run the following code: ```python import numpy as np array = np.array([3, 1, 2, 3, 2, 1, 4]) unique_elements = np.unique(array) print(unique_elements) ``` I get the output `array([1, 2, 3, 4])`, but I expected the unique elements to be in the order they first appeared: `[3, 1, 2, 4]`. I've also tried using the `return_index=True` option, which gives me the indices of the unique elements; however, it adds complexity since I still need to sort those indices to get back to the original order, which doesn't feel efficient. Is there any built-in way to get unique elements while keeping their original order without resorting to additional sorting or processing? Or should I be considering a different approach altogether? I'm using NumPy version 1.21.0, and I want to ensure my solution is both efficient and straightforward. I'm working on a service that needs to handle this. This is my first time working with Python latest. Any advice would be much appreciated.