Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy sort

import numpy as np

arr = np.array([3, 2, 0, 1])
print(np.sort(arr))
# output [0 1 2 3]

arr = np.array(['banana', 'cherry', 'apple'])
print(np.sort(arr))
# output ['apple' 'banana' 'cherry']

arr = np.array([True, False, True])
print(np.sort(arr))
# output [False  True  True]

arr = np.array([[3, 2, 4], [5, 0, 1]])
print(np.sort(arr))
# output
# [[2 3 4]
#  [0 1 5]]
Comment

numpy sort

>>> a = np.array([[1,4],[3,1]])
>>> np.sort(a)                # sort along the last axis
array([[1, 4],
       [1, 3]])
>>> np.sort(a, axis=None)     # sort the flattened array
array([1, 1, 3, 4])
>>> np.sort(a, axis=0)        # sort along the first axis
array([[1, 1],
       [3, 4]])
Comment

numpy array sorting

a = np.array([[1,4],[3,1]])
>>> np.sort(a)                # sort along the last axis
array([[1, 4],
       [1, 3]])
>>> np.sort(a, axis=None)     # sort the flattened array
array([1, 1, 3, 4])
>>> np.sort(a, axis=0)        # sort along the first axis
array([[1, 1],
       [3, 4]])
Comment

How to sort numpy array

np.sort(arr)
array([1, 2, 3, 4, 5, 6, 7, 8])
Comment

numpy.sort

a = np.array([[1,4], [3,1]])
>>> a.sort(axis=1)
>>> a
array([[1, 4],
       [1, 3]])
>>> a.sort(axis=0)
>>> a
array([[1, 3],
       [1, 4]])
Comment

How to sort numpy array

arr=[1,4,2,6,3,5,8,7]
np.sort(arr)
array([1, 2, 3, 4, 5, 6, 7, 8])
Comment

Sort array numpy


arr = np.array([2, 1, 5, 3, 7, 4, 6, 8])
np.sort(arr)
Comment

PREVIOUS NEXT
Code Example
Python :: how to move an item from one list to another python 
Python :: how to clear combobox tkinter 
Python :: receipt data extraction python 
Python :: how to add two strings in python 
Python :: na in python 
Python :: how to convert r to python 
Python :: python daemon 
Python :: dataframe partition dataset based on column 
Python :: pythom Lambda 
Python :: first n prime number finder in python 
Python :: python curses resize window 
Python :: printing with format 
Python :: how to bubble sort a 2d array in python 
Python :: python for loop inside list 
Python :: google codelabs 
Python :: get linkinstance revit api 
Python :: significant figures on axes plot matplotlib 
Python :: Computation failed in `stat_flow()`: 
Python :: empaquetado y manejo dependencias en python 
Python :: how to push the element to array in python 
Python :: compter des valeur consecutives en python 
Shell :: copy ssh key mac 
Shell :: pip upgrade 
Shell :: Failed to start docker.service: Unit docker.service is masked 
Shell :: git user.name user.email 
Shell :: check bios version cmd 
Shell :: remote origin already exists 
Shell :: conda install openpyxl 
Shell :: windows kill port 
Shell :: npm install --global yarn 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =