Sort using a custom comparator: Difference between revisions

Added Oz example.
(added factor example)
(Added Oz example.)
Line 668:
- : string array =
[|"strings"; "sample"; "sorted"; "Here"; "some"; "are"; "be"; "to"|]</lang>
 
=={{header|Oz}}==
<lang oz>declare
fun {LexicographicLessThan Xs Ys}
for
X in {Map Xs Char.toLower}
Y in {Map Ys Char.toLower}
return:Return
default:{Length Xs}<{Length Ys}
do
if X < Y then {Return true} end
end
end
 
fun {LessThan Xs Ys}
{Length Xs} == {Length Ys} andthen {LexicographicLessThan Xs Ys}
orelse
{Length Xs} < {Length Ys}
end
 
Strings = ["Here" "are" "some" "sample" "strings" "to" "be" "sorted"]
in
{ForAll {Sort Strings LessThan} System.showInfo}</lang>
 
=={{header|Perl}}==
Anonymous user