Sort using a custom comparator: Difference between revisions
Content added Content deleted
(→{{header|Smalltalk}}: switched < for >) |
m (Changed over to works with template) |
||
Line 1: | Line 1: | ||
⚫ | |||
{{task}} |
|||
⚫ | |||
'''Note:''' Lexicographic order is case-insensitive. |
'''Note:''' Lexicographic order is case-insensitive. |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
{{works with|GNAT|GPL 2006}} |
|||
===Comparator_Package.ads=== |
===Comparator_Package.ads=== |
||
package Comparator_Package is |
package Comparator_Package is |
||
Line 105: | Line 103: | ||
=={{header|C}}== |
=={{header|C}}== |
||
{{works with|gcc|4.0.1}} |
|||
'''Platform:''' [[BSD]] |
'''Platform:''' [[BSD]] |
||
#include <stdlib.h> |
#include <stdlib.h> |
||
Line 127: | Line 124: | ||
=={{header|C++}}== |
=={{header|C++}}== |
||
{{works with|g++|4.1.2}} |
|||
#include <algorithm> |
#include <algorithm> |
||
#include <string> |
#include <string> |
||
Line 183: | Line 179: | ||
=={{header|D}}== |
=={{header|D}}== |
||
{{works with|D|DMD 1.026}} |
|||
{{libheader|Tango}} |
{{libheader|Tango}} |
||
<pre>module customsort ; |
<pre>module customsort ; |
||
Line 239: | Line 234: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
{{works with|GHC}} |
|||
'''Interpreter:''' [[GHC|GHCi]] |
|||
import List |
import List |
||
import Char |
import Char |
||
Line 274: | Line 269: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
{{works with|Java|1.5+}} |
|||
J2SE 5.0: |
|||
import java.util.Comparator; |
import java.util.Comparator; |
||
import java.util.Arrays; |
import java.util.Arrays; |
||
Line 336: | Line 330: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{works with|Perl|5.8.6}} |
|||
'''Interpreter:''' [[perl]] 5.8.6 |
|||
sub mycmp { length $b <=> length $a or lc $a cmp lc $b } |
sub mycmp { length $b <=> length $a or lc $a cmp lc $b } |
||
Line 343: | Line 337: | ||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
{{works with|PHP|4.4.4 CLI}} |
|||
<?php |
<?php |
||
function mycmp($s1, $s2) |
function mycmp($s1, $s2) |
||
Line 380: | Line 374: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{works with|Python|2.5}} |
|||
'''Interpreter''': 2.5 |
|||
<pre> |
<pre> |
||
def mycmp(s1, s2): |
def mycmp(s1, s2): |