The
Schwartzian Transform is a sorting technique (not just for sorting by length), that keeps you from having to keep from repeatedly calling a potentially slow expensive function in a sort. For more details be sure to check out
this and the
column on sorting
merlyn has listed
there.
-enlil