#!/usr/bin/perl # # $Id: sorting 2592 2003-12-21 00:33:01Z jmates $ # # The author disclaims all copyrights and releases this document into # the public domain. # use Benchmark qw(cmpthese); # sort script itself. use more suitable data sources as needed seek DATA, 0, 0; chomp(@in = ); cmpthese( -5, { 'control' => '@out = @in', 'default' => '@out = sort @in', 'reverse' => '@out = reverse sort @in', 'explicit' => '@out = sort { $a cmp $b } @in', 'substring' => '@out = sort { substr($a, 4, 6) cmp substr($b, 4, 6) } @in', 'insensitive' => '@out = sort { lc $a cmp lc $b } @in', } );