sort help
Paul Rubin
no.email at nospam.invalid
Tue Sep 22 22:40:01 EDT 2015
Larry Martell <larry.martell at gmail.com> 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