Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sort json python

import pprint
# Array of JSON Objects
products = [{"name": "HDD", "brand": "Samsung", "price": "$100"},
            {"name": "Monitor", "brand": "Dell", "price": "$120"},
            {"name": "Mouse", "brand": "Logitech", "price": "$10"}]
'''
Print the sorted JSON objects in descending order
based on the price key value
'''
print("
Array of JSON objects after sorting:")
products = sorted(products, key=lambda k: k['price'], reverse=True)
pprint.pprint((products))
Comment

PREVIOUS NEXT
Code Example
Python :: selenium scroll to element python 
Python :: date parser python pandas 
Python :: pygame event mouse right click 
Python :: python get time difference in milliseconds 
Python :: django not saving images forms 
Python :: longest substring without repeating characters python 
Python :: python zip file open as text 
Python :: crop image python 
Python :: sorted python lambda 
Python :: django foreign key error Cannot assign must be a instance 
Python :: pandas sort values group by 
Python :: add jupyter environment 
Python :: os file exists 
Python :: pandas read csv as strings 
Python :: how to do channel first in pytorch 
Python :: convert number to time python 
Python :: python pandas cumulative return 
Python :: subtract one list from another python 
Python :: how to set index pandas 
Python :: python subtract one list from another 
Python :: capitalize first letter in python 
Python :: force two decimal places python 
Python :: dire Bonjour en python 
Python :: How to Create a Pie Chart in Seaborn 
Python :: inverse matrice python 
Python :: how to find mean of one column based on another column in python 
Python :: python live radio 
Python :: error bar plot python 
Python :: Install Basemap on Python 
Python :: decrypt python code 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =