Sort using a custom comparator: Difference between revisions

Content added Content deleted
No edit summary
Line 786: Line 786:
add
add
Cat</pre>
Cat</pre>
=={{header|Elena}}==
ELENA 3.2.1 :
<lang elena>import extensions.
import system'routines.
import system'culture.

program =
[
var items := ( "Here", "are", "some", "sample", "strings", "to", "be", "sorted" ).
console printLine("Unsorted: ", items).

console printLine("Descending length: ", items clone;
sort(:p:n)(p length > n length) ).

console printLine("Ascending order: ", items clone;
sort(:p:n)(p toUpper(invariantLocale) < n toUpper(invariantLocale)) ).
].</lang>
{{out}}
<pre>
Unsorted: Here,are,some,sample,strings,to,be,sorted
Descending length: strings,sorted,sample,some,Here,are,be,to
Ascending order: are,be,Here,sample,some,sorted,strings,to
</pre>


=={{header|Elixir}}==
=={{header|Elixir}}==