Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Numpy exercise
  • pandas
  • Matplotlib
  • Data visulisation
  • EDA
  • Machin Learning
  • Deep Learning
  • NLP
  • Data science
  • ML Tutorial
  • Computer Vision
  • ML project
Open In App
Next Article:
Python | Numpy matrix.sort()
Next article icon

numpy.sort() in Python

Last Updated : 29 Nov, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report

numpy.sort() : This function returns a sorted copy of an array.

Parameters :

arr : Array to be sorted.
axis : Axis along which we need array to be started.
order : This argument specifies which fields to compare first.
kind : [‘quicksort’{default}, ‘mergesort’, ‘heapsort’]Sorting algorithm.

Return :

Sorted Array




# importing libraries
import numpy as np
  
# sort along the first axis
a = np.array([[12, 15], [10, 1]])
arr1 = np.sort(a, axis = 0)        
print ("Along first axis : \n", arr1)        
  
  
# sort along the last axis
a = np.array([[10, 15], [12, 1]])
arr2 = np.sort(a, axis = -1)        
print ("\nAlong first axis : \n", arr2)
  
  
a = np.array([[12, 15], [10, 1]])
arr1 = np.sort(a, axis = None)        
print ("\nAlong none axis : \n", arr1)
 
 

Output :

Along first axis :    [[10  1]   [12 15]]    Along first axis :    [[10 15]   [ 1 12]]    Along none axis :    [ 1 10 12 15]


Next Article
Python | Numpy matrix.sort()
author
mohit gupta_omg :)
Improve
Article Tags :
  • Python
  • Python numpy-Sorting Searching
  • Python-numpy
Practice Tags :
  • python

Similar Reads

  • Python | Numpy matrix.sort()
    With the help of matrix.sort() method, we are able to sort the values in a matrix by using the same method. Syntax : matrix.sort() Return : Return a sorted matrix Example #1 : In this example we are able to sort the elements in the matrix by using matrix.sort() method. # import the important module
    1 min read
  • numpy.sort_complex() in Python
    numpy.sort_complex() function is used to sort a complex array.It sorts the array by using the real part first, then the imaginary part. Syntax : numpy.sort_complex(arr) Parameters : arr : [array_like] Input array. Return : [complex ndarray] A sorted complex array. Code #1 : # Python program explaini
    1 min read
  • numpy.searchsorted() in Python
    numpy.searchsorted() function is used to find the indices into a sorted array arr such that, if elements are inserted before the indices, the order of arr would be still preserved. Here, binary search is used to find the required insertion indices. Syntax : numpy.searchsorted(arr, num, side='left',
    3 min read
  • sort() in Python
    sort() method in Python sort the elements of a list in ascending or descending order. It modifies the original list in place, meaning it does not return a new list, but instead changes the list it is called on. Example: [GFGTABS] Python a = [5, 3, 8, 1, 2] a.sort() print(a) a.sort(reverse=True) prin
    5 min read
  • Python NumPy
    Numpy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It is the fundamental package for scientific computing with Python. Besides its obvious scientific uses, Numpy can also be used as an efficient
    6 min read
  • Python List sort() Method
    The sort() method in Python is a built-in function that allows us to sort the elements of a list in ascending or descending order and it modifies the list in place which means there is no new list created. This method is useful when working with lists where we need to arranged the elements in a spec
    4 min read
  • numpy.argsort() in Python
    numpy.argsort() is a function in NumPy that returns the indices that would sort an array. In other words, it gives you the indices that you would use to reorder the elements in an array to be in sorted order. Example: [GFGTABS] Python import numpy as geek a = geek.array([2, 0, 1, 5, 4, 1, 9]) print(
    3 min read
  • numpy.greater() in Python
    The numpy.greater() checks whether x1 is greater than x2 or not. Syntax : numpy.greater(x1, x2[, out]) Parameters : x1, x2 : [array_like]Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape out : [ndarray, boolean]Array of bools, or a single bool if x1 and x2 are scala
    2 min read
  • numpy.extract() in Python
    The numpy.extract() function returns elements of input_array if they satisfy some specified condition. Syntax: numpy.extract(condition, array) Parameters : array : Input array. User apply conditions on input_array elements condition : [array_like]Condition on the basis of which user extract elements
    2 min read
  • numpy.argwhere() in Python
    numpy.argwhere() function is used to find the indices of array elements that are non-zero, grouped by element. Syntax : numpy.argwhere(arr) Parameters : arr : [array_like] Input array. Return : [ndarray] Indices of elements that are non-zero. Indices are grouped by element. Code #1 : # Python progra
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences