Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python lambda key sort

>>> student_tuples = [
...     ('john', 'A', 15),
...     ('jane', 'B', 12),
...     ('dave', 'B', 10),
... ]
>>> sorted(student_tuples, key=lambda student: student[2])   # sort by age
[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
Comment

PREVIOUS NEXT
Code Example
Python :: Display an image over another image at a particular co-ordinates in openCV 
Python :: Group by a column, count sum of other columns 
Python :: Customizable TKinter Buttons Python 
Python :: how to print during multiprocessing 
Python :: Javascript rendering html 
Python :: django cleanup 
Python :: color plt 
Python :: how to comment text in python 
Python :: python factor number 
Python :: python multiply string 
Python :: how to declare private attribute in python 
Python :: python string iterate 3 characters at a time 
Python :: pandas dataframe row names 
Python :: join python documentation 
Python :: simple heatmap 
Python :: how to take space separated input in pyhon dicationary 
Python :: obtain items in directory and subdirectories 
Python :: python string to operator 
Python :: dict in dict in python 
Python :: python encode file 
Python :: pip change python version 
Python :: covariance in python 
Python :: drf serializer general validate method 
Python :: flask rest api upload image 
Python :: quantile-quantile plot python 
Python :: python clear stdout 
Python :: Python __mul__ magic method 
Python :: How to Send WhatsApp API using python 
Python :: add a column with initial value to an existing dataframe 
Python :: print all elements in list python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =