WeCodeAcademy

Sorting and Unique Values

np.sort returns a sorted copy. np.argsort returns the order (positions) that would sort the array, handy for sorting one array by another. np.unique removes duplicates, and with return_counts=True it also counts them. Reverse with [::-1].

Examplepython
Open in editor »
Quick check

What does `np.argsort` return?

Your turn: write the code

Print the unique values of the array, sorted.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.