#! /bin/sh
#
###	lensort - sort by line length
###	Usage: lensort [files]

# print each line's length, a TAB and then the actual line.
# By default, awk can run out of fields on long lines;
# setting FS=RS, to make each line one long field, can help.
awk 'BEGIN { FS=RS }
{ print length, $0 }' $* |

# Sort the lines numerically
sort +0n -1 |

# Remove the length and the space and print each line
sed 's/^[0-9][0-9]* //'
