"Shi Mu" wrote:

>I use Python 2.3 to run the following code:
>>>> a=[[1,2],[4,8],[0,3]]
>>>> a.sort()
>>>> a
> [[0, 3], [1, 2], [4, 8]]
>>>>
> I wonder whether the sort function automatically consider the first
> element in the list of list as the sorting criteria or it just happens
> to be?

the documentation has the answer:

    http://docs.python.org/ref/comparisons.html

    "Tuples and lists are compared lexicographically using comparison of
    corresponding elements. This means that to compare equal, each
    element must compare equal and the two sequences must be of the
    same type and have the same length.
    If not equal, the sequences are ordered the same as their first differing
    elements."

</F>



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to