Decorate-sort-undecorate idiom: Difference between revisions

m
→‎alternative: comment alt
m (→‎alternative: one-liner remark)
m (→‎alternative: comment alt)
Line 400:
<span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">vslice</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">s</span>
<span style="color: #000080;font-style:italic;">-- return vslice(sort(columnize({apply(s,f),s})),2)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">decorate_sort_undecorate</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Rosetta Code is a programming chrestomathy site"</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">)</span>
<!--</syntaxhighlight>-->
Same output. YouThe couldcommented useout theline standardshows sortuse ifof youstd putsort theby putting lengths before the words and returnedreturning vslice(s,2), and o/cmaking writeit that asall a one-liner.
 
=={{header|Python}}==
7,820

edits