neocortex wrote: > Hello! > I am a newbie in Python. Recently, I get stuck with the problem of > sorting by two criteria. In brief, I have a two-dimensional list (for > a table or a matrix). Now, I need to sort by two columns, but I cannot > figure out how to do that. I read somewhere that it is possible to do: >>>> table.sort().sort() > but it does not work. > Can anyone help me with this? > PS: I am using Python under Ubuntu 6.06.
You can specify an arbitrary comparison function with the cmp key to sort. IOW, use table.sort(cmp=f), where f is defined to compare table entries (rows?) by whichever criteria are required. -- http://mail.python.org/mailman/listinfo/python-list