sort a file by line length

this
is
a
test

cat test | awk '{ print length, $0 }' | sort -n | cut -d" " -f2-

a
is
test
this