Compare length of two strings: Difference between revisions
→{{header|Ruby}}: Add Ruby
No edit summary |
(→{{header|Ruby}}: Add Ruby) |
||
Line 1,770:
done...
</pre>
=={{header|Ruby}}==
<lang Ruby>
a, b = "Given two strings", "of different length"
[a,b].sort_by{|s| - s.size }.each{|s| puts s + " (size: #{s.size})"}
list = ["abcd","123456789","abcdef","1234567"]
puts list.sort_by{|s|- s.size}
</lang>
{{out}}
<pre>of different length (size: 19)
Given two strings (size: 17)
123456789
1234567
abcdef
abcd</pre>
=={{header|Rust}}==
Line 1,802 ⟶ 1,818:
"e" has length 1 and is the shortest
</pre>
=={{header|Vlang}}==
|