You mean sorting ?

A simple buble sort is good enough (since you never have lots of params)
But instead of comparing the data, compare the length....

Let me try, If i'm faster than you, i'll post it...