From: "Jan E." Date: 2012-03-27T18:04:33+09:00 Subject: Re: sort array of strings with integers Hi, I assume you mean b = %w[a1 a3 a2 a4 a7 a6 a5 a8 a9 a10] Because what you wrote down isn't valid Ruby code. Strings are ordered lexicographically by default. That is, the characters are compared one by one. This makes the string "a10" smaller than "a2", because the character "1" is smaller than "2" (the rest of the string is ignored). If you want to change this behavious, you have to provide your own sorting rule: b.sort_by! {|s| s[/\d+/].to_i} Each element is passed to the block and then the block values are compared. In this case, the elements are compared by the "indices". -- Posted via http://www.ruby-forum.com/.