Use key instead of cmp for sorting.

All uses of `cmp=len_cmp` are replaced by `key=lexico_key`.