Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python dictionary sort in descending order

dict = {"Python":750,"Java":950,"Ruby":700,"C++":200} 
 
sort_values = sorted(dict.items(), key=lambda y: y[1], reverse=True)

for i in sort_values:
	print(i[0], i[1])
Comment

how to sort a list of dictionary by value in descending order?

1. new_list = sorted(old_list, key=lambda k: k['key'], reverse=True)
/*use reverse=False for ascending order*/
Comment

PREVIOUS NEXT
Code Example
Python :: how to append leading zeros in python 
Python :: python list prime numbers 
Python :: how to merge two dictionaries 
Python :: count of datatypes in columns 
Python :: discord.py how to print audit logs 
Python :: pandas create column if equals 
Python :: lower upper in pytho 
Python :: how to create a matrix using python 
Python :: python string indexof 
Python :: 2d dictionary in python 
Python :: isolate row based on index pandas 
Python :: removing whitespaces from pandas dataframe csv 
Python :: plot second axis plotly 
Python :: remove first character of string python 
Python :: google text to speech python 
Python :: python logging into two different files 
Python :: isntall packages to databricks 
Python :: python scheduling 
Python :: rc.local raspberry pi 
Python :: df .sort_values 
Python :: binary representation python 
Python :: discord.py how get user input 
Python :: python all lowercase letters 
Python :: python replace only first instance 
Python :: python get unique pairs from two lists 
Python :: create log in python 
Python :: box plot seaborn python 
Python :: count down for loop python 
Python :: compare two dictionaries in python 
Python :: time 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =