Book Image

NumPy: Beginner's Guide

By : Ivan Idris
Book Image

NumPy: Beginner's Guide

By: Ivan Idris

Overview of this book

Table of Contents (21 chapters)
NumPy Beginner's Guide Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
NumPy Functions' References
Index

Sorting


NumPy has several data sorting routines:

  • The sort() function returns a sorted array

  • The lexsort() function performs sorting with a list of keys

  • The argsort() function returns the indices that will sort an array

  • The ndarray class has a sort() method that performs in-place sorting

  • The msort() function sorts an array along the first axis

  • The sort_complex() function sorts complex numbers by their real part and then their imaginary part

From this list, the argsort() and sort() functions are available as methods on NumPy arrays as well.