Skip to content

Instantly share code, notes, and snippets.

View bearzk's full-sized avatar

Kai Zhang bearzk

View GitHub Profile
@bearzk
bearzk / gist:3717458
Created September 13, 2012 20:38
Python sort using the nth element
>>> a = [(111,555),(333,222)]
>>> a.sort()
>>> a
[(111, 555), (333, 222)]
>>> a.sort(lambda x,y: cmp(x[1],y[1]))
>>> a
[(333, 222), (111, 555)]