sort help

Paul Rubin at nospam.invalid
Wed Sep 23 04:40:01 CEST 2015

Larry Martell <larry.martell at> writes:
>         def GetObjKey(a):
>             return a[2]

This function is called operator.itemgetter:

    from operator import itemgetter
    sorted(a + b + c, key=itemgetter(2))

> So for example, if my initial data was this (I'll only show the fields
> involved with the sort - the first number is a[2] above and the second
> is the new additional sorting field, only present in a)

  sorted(sorted(a, key=itemgetter(5)) + b + c, key = itemgetter(2))

or whatever the new field (instead of 5) is for a.

More information about the Python-list mailing list