Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python sort 2d list

data = [['ABC', 12, 3, 100],
        ['DEF', 10, 5, 200],
        ['GHI', 13, 3, 1000]]

data.sort(key=lambda row: (row[2], row[3]), reverse=True)

print(data)

# [['DEF', 10, 5, 200], ['GHI', 13, 3, 1000], ['ABC', 12, 3, 100]]
Comment

sort 2d list python

>>> sorted(li,key=lambda l:l[1])
[[1, 0.23], [5, 0.27], [4, 0.31], [2, 0.39]]
Comment

PREVIOUS NEXT
Code Example
Python :: linux python virtual environment 
Python :: json.dump 
Python :: python sort array by lambda 
Python :: check how many letters in a string python 
Python :: python string caps lock 
Python :: for i in range python 
Python :: Adding new column to existing DataFrame in Pandas 
Python :: python bool() 
Python :: flask documentation 
Python :: how to print memory address in python 
Python :: how to convert user integer input to string in python 
Python :: python range of array 
Python :: how to use loop in python 
Python :: python list tutorial 
Python :: how to read frame width of video in cv2 
Python :: python value error 
Python :: slider python 
Python :: python chatbot api 
Python :: python list max value 
Python :: python glob how to read all txt files in folder 
Python :: multiline comment 
Python :: how to store object in file python 
Python :: hide password in python 
Python :: print multiple strings in python 
Python :: np.unique 
Python :: armstrong number function 
Python :: how to check if a list is empty in python 
Python :: Dependency on app with no migrations: 
Python :: text to png python 
Python :: number data type in python 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =