All pastes #676967 Raw Edit

Aimaz / Python sorting

public python v1 · immutable
#676967 ·published 2007-08-31 15:37 UTC
rendered paste body
# this code sorts a list of words by their length# largest to smallest# This requires Python 2.4 or above for new __builtin__.sorted w/reverse kw arg optionwords = ["I", "am", "an", "owl"]sorted(((len(w), w) for w in words), reverse=True)