RE: How to sort over dictionaries

2018-08-30 Thread David Raymond
al Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of har...@moonshots.co.in Sent: Thursday, August 30, 2018 4:31 AM To: python-list@python.org Subject: Re: How to sort over dictionaries > > sort = sorted(results, key=lambda res:ite

Re: How to sort over dictionaries

2018-08-30 Thread harish
> > sort = sorted(results, key=lambda res:itemgetter('date')) > > print(sort) > > > > > > I have tried the above code peter but it was showing error like > > TypeError: '<' not supported between instances of 'operator.itemgetter' > > and 'operator.itemgetter' > > lambda res: itemgetter('

Re: How to sort over dictionaries

2018-08-29 Thread Peter Otten
har...@moonshots.co.in wrote: > sort = sorted(results, key=lambda res:itemgetter('date')) > print(sort) > > > I have tried the above code peter but it was showing error like > TypeError: '<' not supported between instances of 'operator.itemgetter' > and 'operator.itemgetter' lambda res: it

Re: How to sort over dictionaries

2018-08-29 Thread harish
> > > On Wednesday, August 29, 2018 at 11:20:26 AM UTC+5:30, John Ladasky wrote: > >> The top-level object you are showing is a list [], not a dictionary {}. > >> It has dictionaries inside of it though. Do you want to sort the list? > >> > >> Python's sorted() function returns a sorted copy of

RE: How to sort over dictionaries

2018-08-29 Thread David Raymond
m: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of har...@moonshots.co.in Sent: Tuesday, August 28, 2018 11:56 PM To: python-list@python.org Subject: How to sort over dictionaries [, https://getbootstrap.com/', 'author': 'Hari'

How to sort over dictionaries

2018-08-29 Thread harish
[, https://getbootstrap.com/', 'author': 'Hari', 'date': '15-08-2018 15:15', 'headline': 'latest news'}>, , https://www.deps.co/blog/google-cloud-platform-good-bad-ugly/', 'author': 'Harish', 'headline': 'Google Cloud Platform – The Good, Bad, and Ugly', 'date': '16-08-2018 08:15'}>, , , http:

Re: How to sort over dictionaries

2018-08-29 Thread Peter Otten
har...@moonshots.co.in wrote: > On Wednesday, August 29, 2018 at 11:20:26 AM UTC+5:30, John Ladasky wrote: >> The top-level object you are showing is a list [], not a dictionary {}. >> It has dictionaries inside of it though. Do you want to sort the list? >> >> Python's sorted() function return

Re: How to sort over dictionaries

2018-08-29 Thread harish
On Wednesday, August 29, 2018 at 11:20:26 AM UTC+5:30, John Ladasky wrote: > The top-level object you are showing is a list [], not a dictionary {}. It > has dictionaries inside of it though. Do you want to sort the list? > > Python's sorted() function returns a sorted copy of a sequence. Sort

Re: How to sort over dictionaries

2018-08-28 Thread John Ladasky
The top-level object you are showing is a list [], not a dictionary {}. It has dictionaries inside of it though. Do you want to sort the list? Python's sorted() function returns a sorted copy of a sequence. Sorted() has an optional argument called "key". Key accepts a second function which c