[Python-il] Self containment
Rani Hod
rani.hod at gmail.com
Mon Nov 14 02:01:40 IST 2011
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<--------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://hamakor.org.il/pipermail/python-il/attachments/20111114/e67d4363/attachment.htm>
More information about the Python-il
mailing list