Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python sort a 2d array by custom function

>>> a = [
     [12, 18, 6, 3], 
     [ 4,  3, 1, 2], 
     [15,  8, 9, 6]
]
>>> a.sort(key=lambda x: x[1])
>>> a
[[4,  3,  1, 2], 
 [15, 8,  9, 6], 
 [12, 18, 6, 3]]
Comment

PREVIOUS NEXT
Code Example
Python :: R sample() funciton in python 
Python :: bmi calculator in python 
Python :: atan2 of number python 
Python :: turtle example 
Python :: how to find a prime number 
Python :: python frozenset() 
Python :: with open 
Python :: if condition in print statement python 
Python :: save pillow image to database django 
Python :: mkvirtualenv python version 
Python :: python modules 
Python :: sympy 
Python :: variables and data types in python 
Python :: python scheduler 
Python :: download unsplash images python 
Python :: django forms date picker 
Python :: adfuller test in python 
Python :: get coordinates in xarray 
Python :: python staticmethod property 
Python :: get drive path python 
Python :: flask run 
Python :: expand alphabets in python 
Python :: django update field after save 
Python :: python sort 
Python :: Disctionary to Array 
Python :: decimal to binary python 
Python :: python to postgresql 
Python :: confusion matrix 
Python :: django admin readonly models 
Python :: filter directory in python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =