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