Help for this page

Select Code to Download


  1. or download this
    # cmp. Generic, "smart" three-way comparator.
    
    ...
    
    # Compares strings with string semantics, numbers with number semantic
    +s, Pair objects first by key and then by value etc.
    # if $a eqv $b, then $a cmp $b always returns Order::Same. Otherwise O
    +rder::Less or Order::More.
    
  2. or download this
    dd 'a ä b'.comb.sort;
    (" ", " ", "a", "b", "ä").Seq;
    
  3. or download this
    subset CzechString of String;
    multi sub infix:<cmp>(CzechString $a, CzechString $b) {
      # sort logic here
    }
    
  4. or download this
    sub czech-sort(String $a, String $b) {
      # sort logic here
    }
    
    @czech-words.sort( &czech-sort );
    
  5. or download this
    dd ([1,'z'], [2,'a'], ['1', 'a']).sort( *.[0,1] );
    (["1", "a"], [1, "z"], [2, "a"]).Seq
    
    dd ([1,'z'], [2,'a'], ['1', 'a']).sort( { $^a[0] <=> $^b[0] || $^a[1] 
    +cmp $^b[1] });