The msort()
function in Python is simply used to return a copy of an array sorted along the first axis.
numpy.msort(a)
The msort()
function takes a single and mandatory parameter value a
, which represents the input array to be sorted.
The msort()
function returns an array of the same type and shape as the input array a
passed to it.
Let’s see how to use to it through the following code example.
import numpy as np# creating lists of numbersmyarray = np.array([[3, 5, 2, 4, 1], [9, 6, 10, 8, 7]])# implementing the lexsort() function to sort mylist1 firstsortedarray = np.msort(myarray)print(sortedarray)
numpy
module.2D
array using the array()
functionmsort()
function on the array myarray
. The result is assigned to a variable sortedarray
.sortedarray
.