Ярлыки

суббота, 3 ноября 2012 г.

Python: sorting of the "table" (list of lists)


There is list like "list of the lists": [[1,2,3],[4,5,6],[7,8,9],[11,
12,13],[14,15,16]]
We can sort it by follow script:

import operator
...
myList.sort(key=operator.itemgetter(3))
 
If we can see cortege of number of "columns" in itemgetter (for example: (0,1)), there is sorting order in this cortege.

Комментариев нет:

Отправить комментарий