How do I sort this:
arr = ["aaa","aa","aaaa","a","aaaaa"];
Into this?
arr = ["a","aa","aaa","aaaa","aaaaa"];
arr = arr.sort_by {|x| x.length}
Or in 1.8.7+:
arr = arr.sort_by(&:length)
1.4m articles
1.4m replys
5 comments
57.0k users