Shell tricks: sort a Bash array by length

I’m certain there’s a more elegant way to do this, but I couldn’t find it. I needed to sort a Bash array of strings by the length of each element without getting too verbose. Here’s what I came out with: