Help for this page

Select Code to Download


  1. or download this
    # for @foo with 100,000 elements, this sort eats 12k of memory
    @foo = sort { $foo->{bar} cmp $foo->{bar} } @foo;
    ...
    # but for the same foo, this sort eats 90M !
    @foo = sort @foo;
    @foo = sort { $a cmp $b } @foo; # equivalent
    
  2. or download this
    # requires scads of memory
    @array_of_refs = sort { $a cmp $b } @array_of_refs;
    ...
    # doesn't
    @array_of_simple_scalars = sort { \$a cmp \$b }
      @array_of_simple_scalars;
    
  3. or download this
    # scads
    @array_of_stringrefs = sort { ('a: '.$a) cmp ('b: ".$b) }
    ...
    #scadless
    @array_of_stringrefs = sort { ('a: '.$$a) cmp ('b: ".$$b) }
      @array_of_stringrefs