Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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)
Source by www.pythontutorial.net #
 
PREVIOUS NEXT
Tagged: #python #sort #highest #number
ADD COMMENT
Topic
Name
2+2 =