i have json file:
ll = {"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"James", "lastName":"Bond"},
{"firstName":"Celestial", "lastName":"Systems"},
{"firstName":"Peter", "lastName":"Jones"}
]}
i want to sort by key(lastname or firstname)
i know the sorting method that we use with number as value but i am not able to sort this by value as string.
i tried below:
#data = json.load(file)
new = sorted(data, key = lambda k: k['employees'].get('lastName',0))
and getting error:
TypeError: string indices must be integers