On Monday, August 17, 2015 at 7:32:08 PM UTC+5:30, Владислав wrote:
> # first: works fine
> x = [1, 2, 4, 2, 1, 3]
> x = list(set(x))
> x.sort()
> print(x) # output: 1, 2, 3, 4
>
> # second: why x became None ??
> x = [1, 2, 4, 2, 1, 3]
> x = list(set(x)).sort()
> print(x) # output: None
> I kno
On 17/08/2015 12:42, Владислав wrote:
# first: works fine
x = [1, 2, 4, 2, 1, 3]
x = list(set(x))
x.sort()
print(x) /# output: 1, 2, 3, 4
/# second: why x became None ??
x = [1, 2, 4, 2, 1, 3]
x = list(set(x)).sort()
print(x) /# output: None/
I know that sort() returns None, but I guess that
On 08/17/2015 01:42 PM, Владислав wrote:
x = [1, 2, 4, 2, 1, 3]
x = list(set(x)).sort()
print(x) /# output: None/
I know that sort() returns None, but I guess that it would be returned x
that was sorted. Why so?
If sort() returns None, than the following:
x = list(set(x)).sort()
is equivalen
>
> I know that sort() returns None, but I guess that it would be returned x
> that was sorted. Why so?
if it returned a sorted list it might lead some people to believe it
did not modify the oridinal list which would lead to a ton of
confusion for new users.
--
https://mail.python.org/mailman/li
# first: works fine
x = [1, 2, 4, 2, 1, 3]
x = list(set(x))
x.sort()
print(x) # output: 1, 2, 3, 4
# second: why x became None ??
x = [1, 2, 4, 2, 1, 3]
x = list(set(x)).sort()
print(x) # output: None
I know that sort() returns None, but I guess that it would be returned x
that was sorted. Wh
Michele Petrazzo <[EMAIL PROTECTED]> wrote:
> Lasse Vågsæther Karlsen wrote:
> > How about:
> >
> > list.sort(key=lambda x: x[3])
> >
> > Does that work?
>
> Yes, on my linux-test-box it work, but I my developer pc I don't have
> the 2.4 yet. I think that this is a good reason for update :)
Up
Kent Johnson wrote:
> or learn about decorate-sort-undecorate:
>
> lst = [ ...whatever ] lst = [ x[3], i, x for i, x in enumerate(lst) ]
>
I think that here the code must be changed (for the future):
lst = [ (x[3], i, x) for i, x in enumerate(lst) ]
> lst.sort() lst = [ x for _, _, x in lst ]
Michele Petrazzo wrote:
> Lasse Vågsæther Karlsen wrote:
>
>> How about:
>>
>> list.sort(key=lambda x: x[3])
Better to use key=operator.itemgetter(3)
> Yes, on my linux-test-box it work, but I my developer pc I don't have
> the 2.4 yet. I think that this is a good reason for update :)
or learn
Lasse Vågsæther Karlsen wrote:
> How about:
>
> list.sort(key=lambda x: x[3])
>
> Does that work?
>
Yes, on my linux-test-box it work, but I my developer pc I don't have
the 2.4 yet. I think that this is a good reason for update :)
Thanks,
Michele
--
http://mail.python.org/mailman/listinfo/py
How about:
list.sort(key=lambda x: x[3])
Does that work?
--
http://mail.python.org/mailman/listinfo/python-list
I have a list of lists (a grid table) that can have about 15000 - 2
"rows" and 10 "cols", so:
1 [ [ 'aaa', 'vv', 'cc', 23, ... ],
2 [ 'aav', 'vv', 'cc', 45, ... ],
...
15000 [ 'sad', 'ad', 'es', 123, ... ], ]
I need to sort this list, but I need to specify two things: the "column"
11 matches
Mail list logo