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 :: add one day to datetime 
Python :: pywebcopy 
Python :: discord py edit message 
Python :: how to open pickle file 
Python :: python list splicing 
Python :: remove last line of text file python 
Python :: python float to decimal 
Python :: if else python in single line 
Python :: how to remove all 2 in a list python 
Python :: pyside 
Python :: python remove first substring from string 
Python :: mailchimp send email python 
Python :: get context data django 
Python :: dimension of tensor 
Python :: difference between two dictionaries python 
Python :: remove substring from string python 
Python :: combine dataframes with two matching columns 
Python :: python grid 
Python :: python define an array of dictonary 
Python :: flask blueprint static folder 
Python :: convert pdf to csv python 
Python :: Pyspark Aggregation on multiple columns 
Python :: Example of lambda function in python with list 
Python :: reshape wide to long in pandas 
Python :: find the highest 3 values in a dictionary. 
Python :: add time and date to datetime 
Python :: levenshtein distance 
Python :: python string indexing 
Python :: pandas read excel with two headers 
Python :: git help 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =