NumPy sort: Sort an array by ascending or descending

NumPy has sort function sorting an array ascending.

import numpy

a = numpy.array([2, 1, 5, 4, 3])

b = numpy.sort(a)
c = numpy.sort(a)[::-1]

print(b)  # [1 2 3 4 5]
print(c)  # [5 4 3 2 1]

You can sort an array by descending adding [::-1] to the sorted array. [::-1] reverses an array.

NumPy Array

NumPy Tutorial