Answers for "sort column in numpy array"

1

sort array python by column

Sorting a NumPy array by a column orders its rows based 
on the ordering of the values in the column. 
For example, sorting the array [[8 2 -2] [-4 1 7] [6 3 9]] 
by its second column returns [[-4 1 7] [8 2 -2] [6 3 9]].
USE numpy.args

sorted_array = an_array[numpy.argsort(an_array[:, 1])]
Posted by: Guest on August-17-2020
0

how to sort values in numpy by one column

sorted_array = an_array[numpy.argsort(an_array[:, 1])]
Posted by: Guest on January-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language