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
> > 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('
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
>
> > 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
Well, that's a list of... somethings. So I'm assuming you mean sort a list of
dictionaries?
foo.sort(key = lambda x: time.strptime(x["date"], "%d-%m-%Y %H:%M"))
with , reverse = True in the sort if you want it sorted in reverse
-Original Message-
From: Python-list
[mailto:python-list
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
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
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