Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sort first element reverse sort second python

>>> sorted(lista, key=lambda x: (-x[0], x[1]))
[(485, 'Elizabeth'), (485, 'Matthew'), (390, 'Jayden'), (207, 'Natalie'), (144, 'Chloe'), (51, 'Elijah')]
Comment

PREVIOUS NEXT
Code Example
Python :: django query multiple conditions 
Python :: randomly shuffle pandas dataframe 
Python :: python string remove accent 
Python :: sqlalchemy one to many 
Python :: MAKE A SPHERE IN PYTHON 
Python :: button tkinter 
Python :: pygame point at mouse 
Python :: separating tuple in pandas 
Python :: how to do a print statement in python 
Python :: asyncio run 
Python :: how to create adjacency matrix from adjacency list in python 
Python :: django deployment 
Python :: inverse matrix python numpy 
Python :: seaborn pink green color palette python 
Python :: Python numpy.broadcast_to() Function Example 
Python :: print in python 
Python :: python read binary trj file 
Python :: argparse cli 
Python :: Fast api importing optional 
Python :: group multiple columns in pandas 
Python :: subarray in python 
Python :: python strip 
Python :: python smtp sendmail 
Python :: python compare floats 
Python :: python replace null in list 
Python :: tkinter datatypes 
Python :: python sets 
Python :: multiple lines input python 
Python :: how to check dimension of array in python 
Python :: python snake case to camel case 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =