Sorting a list
Shae Erisson
shapr at uab.edu
Fri Jun 2 14:22:43 EDT 2000
Aaron Ginn wrote:
>
> I'm a python newbie, so please be kind! :)
>
> I'm trying to sort a list. Fairly simple, but I'm not getting
> at all what I expect. When I attempt to sort the list, the
> return value is None, and I can't understand why at all.
<snip>
> Why is sort returning an empty list?
because in this case, sort is expected to have the side effect of
sorting the list, rather than returning a sorted list.
>>> a = [3,2,1]
>>> a.sort()
>>> a
[1, 2, 3]
--
sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre
bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt
More information about the Python-list
mailing list