Advertisement
petrlos

Numpy Sorted Array

Dec 5th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. import numpy
  2. from random import randint
  3.  
  4. numpyArray = numpy.zeros((5,5), int)
  5.  
  6. for row in range(5):
  7.     for column in range(5):
  8.         numpyArray[(row, column)] = randint(0,1)
  9.  
  10. print(numpyArray)
  11.  
  12. sortedArray = numpyArray[numpyArray[:, 1].argsort()]
  13. print(sortedArray)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement