Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python sort by highest number

companies = [('Google', 2019, 134.81),
             ('Apple', 2019, 260.2),
             ('Facebook', 2019, 70.7)]
# define a sort key
def sort_key(company):
    return company[2]
# sort the companies by revenue
companies.sort(key=sort_key, reverse=True)
# show the sorted companies
print(companies)
Code language: Python (python)
Comment

PREVIOUS NEXT
Code Example
Python :: codechef solution 
Python :: .counter python 
Python :: execute command in python 
Python :: print format python 
Python :: python 2 print in same line 
Python :: reading from a file in python 
Python :: multiple inputs in one line- python 
Python :: solve linear system python 
Python :: get request in django 
Python :: cache pyspark 
Python :: print colors in python 
Python :: binary to decimal python 
Python :: Add two numbers as a linked list 
Python :: call matlab function from python 
Python :: Python Create a nonlocal variable 
Python :: {% load humanise %} 
Python :: python integer to string format 
Python :: stack adt in python 
Python :: python merge two array into one 
Python :: pandas difference between two dataframes 
Python :: get type name python 
Python :: pandas describe 
Python :: how to get text of a tag in selenium python 
Python :: use functions to resample python 
Python :: pandas read csv specify column dtype 
Python :: pandas count occurrences of certain value in row 
Python :: print only strings in list python 
Python :: function to perform pairs bootstrap estimates on linear regression parameters 
Python :: cronometro python tkinter 
Python :: how to open a file in python 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =