Sort 1D and 2D arrays with np.sort() and retrieve sorted index order with np.argsort().
`np.sort()` returns a sorted copy of an array using optimized C-level quicksort. `np.argsort()` returns the index order that sorts the array.
`np.sort` organizes runners by their finishing times. `np.argsort` lists the jersey numbers of runners in order of who crossed the finish line first.
`np.sort(arr)` returns sorted values. `np.argsort(arr)` returns an index permutation array, which is essential for sorting parallel columns in datasets.
s = np.sort(arr); idx = np.argsort(arr)arr.sort() # Mutates original array in place without returning itsorted_arr = np.sort(arr) # Returns sorted copy safely`np.sort(arr)` returns a new array; `arr.sort()` mutates in-place and returns None.
Solve the objective below using NumPy vectorized syntax
Create `arr = np.array([30, 10, 50, 20])`, sort it using `np.sort(arr)`, and print.
[10 20 30 50]