In this python numpy program, we will sort an array by column in ascending order using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array().
- Sort an array by column in ascending order using np.sort() and set the axis equal to 0.
- Print the output.
				
					import numpy as np
x = np.array([[6, 5],
              [10, 9],
              [8, 7]])
print("Sorting matrix by column: ")
print(np.sort(x,axis=0)) 
				
			
		Output :
				
					Sorting matrix by column: 
[[ 6  5]
 [ 8  7]
 [10  9]]