Use data[np.argsort(data[:, 0])]
where the 0
is the column index on which to sort:
In [27]: import numpy as np
In [28]: data = np.array([[5,2], [4,1], [3,6]])
In [29]: col = 0
In [30]: data=data[np.argsort(data[:,col])]
Out[30]:
array([[3, 6],
[4, 1],
[5, 2]])
More Related Contents:
- Sorting arrays in NumPy by column
- Find elements of array one nearest to elements of array two
- Sort invariant for numpy.argsort with multiple dimensions
- Efficiently sorting a numpy array in descending order?
- argsort for a multidimensional ndarray
- Find the row indexes of several values in a numpy array
- What are the differences between numpy arrays and matrices? Which one should I use?
- Working with big data in python and numpy, not enough ram, how to save partial results on disc?
- How to apply a disc shaped mask to a NumPy array?
- How to remove specific elements in a numpy array
- Find nearest indices for one array against all values in another array – Python / NumPy
- Get the position of the largest value in a multi-dimensional NumPy array
- Convert a 1D array to a 2D array in numpy
- Using Numpy Vectorize on Functions that Return Vectors
- How to extend an array in-place in Numpy?
- np arrays being immutable – “assignment destination is read-only”
- Numpy individual element access slower than for lists
- How to turn a video into numpy array?
- Can numpy bincount work with 2D arrays?
- Numpy isnan() fails on an array of floats (from pandas dataframe apply)
- Concatenate range arrays given start, stop numbers in a vectorized way – NumPy
- Numpy – Replace a number with NaN
- Python: how to store a numpy multidimensional array in PyTables?
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- How does the axis parameter from NumPy work?
- Numpy Array Get row index searching by a row
- Resample a numpy array
- Creating a numpy array of 3D coordinates from three 1D arrays
- How to use Python multiprocessing Pool.map to fill numpy array in a for loop
- Is this the best way to add an extra dimension to a numpy array in one line of code?