Compare length of two strings: Difference between revisions

(J: simplify (though the language lesson stuff will remain in wiki history, should that be of interest...))
Line 1,231:
fun comparator = int by text a, text b do return b.length <> a.length end
List sorted = list.sort(comparator)
writeLine("text".padEnd(15, " ") + "charsunits".padStart(6, " ") + "bytes".padStart(6, " "))
for each text value in sorted
writeLine(value.padEnd(15, " ") +
Line 1,241:
{{out}}
<pre>
text charsunits bytes
Привет, мир 11 20
123456789 9 9
218

edits