Perl-Python-a-Day: Sorting
Diez B. Roggisch
deets at nospam.web.de
Thu Oct 13 04:03:51 EDT 2005
> In Perl, sort is a function, not some Object Oriented thing. It returns
> the sorted result as another list. This is very simple and nice.
And sometimes exteremely stupid - if your list is large, and making a
copy just form sorting it (when you don't have to keep a referenece to
the old list) is highly inefficient.
Calling this stupid tells us just a little bit more of your total lack
of programming fundamentals.
Not to mention that writing a helper function
def sorted(l):
l = l[:]
l.sort()
return l
to have sorted in versions below 2.4 isn't exactly "magic." But hey,
we're talking about Xah Lee, a guy who believes his hair could have
saved the world [1]....
Diez
[1] http://xahlee.org/PageTwo_dir/Personal_dir/mi_pixra.html
More information about the Python-list
mailing list