Name

sort

Synopsis

sort(a,axis=-1)

Returns an array s with the same type code and shape as a, with elements along each plane of the given axis reordered so that the plane is sorted in increasing order. For example:

# x is [[0 1 2 3]
#       [4 0 1 2]
#       [3 4 0 1]]
print Numeric.sort(x)       # prints: [[0 1 2 3]
                            #          [0 1 2 4]
                            #          [0 1 3 4]]
print Numeric.sort(x,0)     # prints: [[0 0 0 1]
                            #          [3 1 1 2]
                            #          [4 4 2 3]]

sort( x ) returns a result where each row is sorted. sort( x ,0) returns a result where each column is sorted.

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.