Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Rani Hod <rani.hod <at> gmail.com>
Subject: Self containment
Newsgroups: gmane.comp.python.israel
Date: Monday 14th November 2011 00:01:40 UTC (over 5 years ago)
Dear Abby,

Any idea why sorted and list.sort behave differently in the following
example?
(specifically, why x is not sorted in the end?)

Thanks,
R.

------------8<--------------------8<--------
>>> x = ['one','two','three']; x.append(x)
>>> sorted(x, key=len)
['one', 'two', ['one', 'two', 'three', [...]], 'three']
>>> x.sort(key=len); x
[[...], 'one', 'two', 'three']
------------8<--------------------8<--------
 
CD: 3ms