Charles Heizer wrote:
> On Monday, March 2, 2015 at 11:23:37 AM UTC-8, Peter Otten wrote:
>> Charles Heizer wrote:
>>
>> > Never mind, the light bulb finally went off. :-\
>> >
>> > sortedlist = sorted(mylist , key=lambda elem: "%s %s" % ( elem['name'],
>> > (".".join([i.zfill(5) for i in elem['
On Tuesday, 3 March 2015 16:09:31 UTC, Chris Angelico wrote:
> On Wed, Mar 4, 2015 at 2:56 AM, Charles Heizer wrote:
> >> Personally, I prefer to not use a lambda:
> >>
> >> def name_version(elem):
> >> return elem['name'], LooseVersion(elem['version'])
> >>
> >> result = sorted(mylist, key=na
On Wed, Mar 4, 2015 at 2:56 AM, Charles Heizer wrote:
>> Personally, I prefer to not use a lambda:
>>
>> def name_version(elem):
>> return elem['name'], LooseVersion(elem['version'])
>>
>> result = sorted(mylist, key=name_version, reverse=True)
>
> Peter, thank you. Me being new to Python why
On Monday, March 2, 2015 at 11:23:37 AM UTC-8, Peter Otten wrote:
> Charles Heizer wrote:
>
> > Never mind, the light bulb finally went off. :-\
> >
> > sortedlist = sorted(mylist , key=lambda elem: "%s %s" % ( elem['name'],
> > (".".join([i.zfill(5) for i in elem['version'].split(".")])) ),
> >
On Wed, Mar 4, 2015 at 1:45 AM, Jason Friedman wrote:
> I appreciate
> how Python makes my job easier by doing much of my work for me. A
> colleague yesterday asked how I guaranteed my temporary file names
> would not collide with another file, and my answer was I don't have to
> worry about it,
On Tue, Mar 3, 2015 at 12:07 AM, Chris Angelico wrote:
> Heh, I think that mght be a bit abusive :) I'm not sure that
> you want to depend on the version numbers fitting inside the rules for
> IP addresses, especially given that the example has a component of
> "2214".
>
Indeed, I was mi
Charles Heizer wrote:
> Hello,
> I'm new to python and I'm trying to find the right way to solve this issue
> I have.
>
> I'm trying to sort this list by name and then by version numbers. The
> problem I'm having is that I can not get the version numbers sorted with
> the highest at the top or so
On Tue, Mar 3, 2015 at 4:33 PM, Jason Friedman wrote:
>>> This is what I was trying but LooseVersion() was not sorting version
>>> numbers like I thought it would. You will notice that Chrome version
>>> "40.0.2214.111" is higher than "40.0.2214.91" but in the end result it's
>>> not sorting it
>> This is what I was trying but LooseVersion() was not sorting version numbers
>> like I thought it would. You will notice that Chrome version "40.0.2214.111"
>> is higher than "40.0.2214.91" but in the end result it's not sorting it that
>> way.
>
> Because it's a string they're sorted lexicog
Charles Heizer wrote:
> Never mind, the light bulb finally went off. :-\
>
> sortedlist = sorted(mylist , key=lambda elem: "%s %s" % ( elem['name'],
> (".".join([i.zfill(5) for i in elem['version'].split(".")])) ),
> reverse=True)
This lightbulb will break with version numbers > 9 ;)
Here a
Never mind, the light bulb finally went off. :-\
sortedlist = sorted(mylist , key=lambda elem: "%s %s" % ( elem['name'],
(".".join([i.zfill(5) for i in elem['version'].split(".")])) ), reverse=True)
On Monday, March 2, 2015 at 10:40:30 AM UTC-8, Charles Heizer wrote:
> Sorry,
>
> sortedlist = s
On 03/02/2015 01:38 PM, Charles Heizer wrote:
Sorry,
sortedlist = sorted(mylist , key=lambda elem: "%s %s" % (elem['name'],
LooseVersion(elem['version'])), reverse=True)
This is what I was trying but LooseVersion() was not sorting version numbers like I thought it
would. You will notice that
On Mon, Mar 2, 2015 at 11:38 AM, Charles Heizer wrote:
> Sorry,
>
> sortedlist = sorted(mylist , key=lambda elem: "%s %s" % (elem['name'],
> LooseVersion(elem['version'])), reverse=True)
>
> This is what I was trying but LooseVersion() was not sorting version numbers
> like I thought it would. Y
Sorry,
sortedlist = sorted(mylist , key=lambda elem: "%s %s" % (elem['name'],
LooseVersion(elem['version'])), reverse=True)
This is what I was trying but LooseVersion() was not sorting version numbers
like I thought it would. You will notice that Chrome version "40.0.2214.111" is
higher than "
On 3/2/2015 10:17 AM, Charles Heizer wrote:
Hello,
I'm new to python and I'm trying to find the right way to solve this issue I
have.
I'm trying to sort this list by name and then by version numbers. The problem
I'm having is that I can not get the version numbers sorted with the highest at
t
Hello,
I'm new to python and I'm trying to find the right way to solve this issue I
have.
I'm trying to sort this list by name and then by version numbers. The problem
I'm having is that I can not get the version numbers sorted with the highest at
the top or sorted properly.
mylist = [{'name'
http://wiki.python.org/moin/HowTo/Sorting#Topicstobecovered
Works fine. Thanks a lot for your help, Stefan.
Regards
Nico
--
http://mail.python.org/mailman/listinfo/python-list
Nico Grubert wrote:
> Thanks a lot Stefan & Peter.
>
> I'm almost there (except sorting of umlauts does not work yet).
>
>
> import locale
locale.setlocale(locale.LC_ALL, "")
> def sorted(items, key):
> decorated = [(key(item), index, item) for index, item in
>enumera
Nico Grubert, 13.01.2010 16:18:
print sorted(items, key=lambda d: locale.strxfrm(d.get('title')))
-> [{'id': 2, 'title': 'The Storm'}, {'id': 4, 'title': 'The thunder'},
{'id': 3, 'title': 'the bible'}, {'id': 1, 'title': 'the \xc4hnlich'}]
The entry with the umlaut is the last item in but ac
Thanks a lot Stefan & Peter.
I'm almost there (except sorting of umlauts does not work yet).
import locale
def sorted(items, key):
decorated = [(key(item), index, item) for index, item in
enumerate(items)]
decorated.sort()
return [item[2] for item in decorated]
i
Peter Otten, 13.01.2010 13:25:
>>> items = "Atem Äther ähnlich anders".split()
>>> print " ".join(sorted(items, key=lambda s: s.lower()))
If you can make sure that 's' is either always a byte string or always a
unicode string (which is good programming practice anyway), an unbound
method can
Nico Grubert wrote:
>> Er, that should have been mylist.sort(key = lambda d:
>> d['title'].lower()) of course.
>
>
> Thanks a lot for the tip, chris.
> Unfortunately, I only have Python 2.3.5 installed and can't upgrade to
> 2.4 due to an underliying application server.
>
> In python 2.3 the '
Er, that should have been mylist.sort(key = lambda d:
d['title'].lower()) of course.
Thanks a lot for the tip, chris.
Unfortunately, I only have Python 2.3.5 installed and can't upgrade to
2.4 due to an underliying application server.
In python 2.3 the 'sort()' function does not excepts a
Nico Grubert writes:
> Hi there
>
> I have the following list 'mylist' that contains some dictionaries:
>
> mylist = [{'title':'the Fog', 'id':1},
> {'title':'The Storm', 'id':2},
> {'title':'the bible', 'id':3},
> {'title':'The thunder', 'id':4}
> ]
>
> How
On Wed, Jan 13, 2010 at 2:41 AM, Chris Rebert wrote:
> On Tue, Jan 12, 2010 at 11:45 PM, Nico Grubert wrote:
>> Hi there
>>
>> I have the following list 'mylist' that contains some dictionaries:
>>
>> mylist = [{'title':'the Fog', 'id':1},
>> {'title':'The Storm', 'id':2},
>> {'
Nico Grubert wrote:
> I have the following list 'mylist' that contains some dictionaries:
>
> mylist = [{'title':'the Fog', 'id':1},
>{'title':'The Storm', 'id':2},
>{'title':'the bible', 'id':3},
>{'title':'The thunder', 'id':4}
> ]
>
> How I can so
On Tue, Jan 12, 2010 at 11:45 PM, Nico Grubert wrote:
> Hi there
>
> I have the following list 'mylist' that contains some dictionaries:
>
> mylist = [{'title':'the Fog', 'id':1},
> {'title':'The Storm', 'id':2},
> {'title':'the bible', 'id':3},
> {'title':'The thunder',
Hi there
I have the following list 'mylist' that contains some dictionaries:
mylist = [{'title':'the Fog', 'id':1},
{'title':'The Storm', 'id':2},
{'title':'the bible', 'id':3},
{'title':'The thunder', 'id':4}
]
How I can sort (case insensitive) the list b
28 matches
Mail list logo