Decorate-sort-undecorate idiom: Difference between revisions
→{{header|Lua}}
(Created Nim solution.) |
|||
Line 622:
<pre>a is site Code Rosetta programming chrestomathy
chrestomathy programming Rosetta Code site is a</pre>
However, for this same reason, there is no point doing the decorate, sort, undecorate in practice. You can simply do this:
<syntaxhighlight lang="lua">function lengthOrder (a, b)
return #a < #b
end
local list = {"Rosetta", "Code", "is", "a", "programming", "chrestomathy", "site"}
table.sort(list, lengthOrder)
print(unpack(list))</syntaxhighlight>
{{out}}
<pre>a is site Code Rosetta programming chrestomathy</pre>
=={{header|Nim}}==
|