Python Numpy sort_complex()

Description
NumPy generally stands for Numerical Python and it is a general purpose array processing package.it always provides a high performance multidimensional array object. Numpy is usually for creating an array of n dimensions.

Method Name :numpy.sort_complex(arr)
Description : The function is used to sort a complex array.It sorts the array by using the real part first, then the imaginary part. Sorting refers to arranging data in a particular format. The sorting algorithm specifies the way to arrange data in a particular order. Most common orders are in numerical or lexicographical order. In Numpy, we can perform various sorting operations using the various functions that are provided in the library like sort, lexsort, argsort, etc.This function returns a sorted copy of an array.

Parameter Name: arr
Description : Input array

Parameter Name:numpy.ndarray.sort()
Description : Sort an array, in-place.

Parameter Name:numpy.msort()
Description : Return a copy of an array sorted along the first axis.

Parameter Name: numpy.sort_complex()
Description : Sort a complex array using the real part first, then the imaginary part.

Parameter Name: numpy.partition()
Description : Return a partitioned copy of an array.

Parameter Name: numpy.argpartition()
Description : Perform an indirect partition along the given axis using the algorithm specified by the kind keyword.

The first step would be to give syntax
command:
numpy.sort_complex(arr)

Example :
Code :
# sort_complex() function import numpy as geek # input array in_arr = [2 + 4j, 5 + 9j, 3 - 2j, 4 - 3j, 3 + 5j, 2-4j, 5] print ("Input array : ", in_arr) out_arr = geek.sort_complex(in_arr) print ("Output sorted array : ", out_arr)

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

Output :