#!/usr/bin/perl use strict; use warnings; use Benchmark qw /timethese cmpthese/; our @advocates = map {{fld_title => 'Rec' . $_, fld_type => [qw /National State Local/] -> [rand 3]}} 1 .. shift || 1000; our %order = (LOCAL => 'A', STATE => 'B', NATIONAL => 'C'); our %order_r = reverse %order; our (@limbic, @GRT); cmpthese -1 => { limbic => '@limbic = sort {$order {uc $a -> {fld_type}} cmp $order {uc $b -> {fld_type}} or $a -> {fld_title} cmp $b -> {fld_title}} @advocates', GRT => '@GRT = map {{fld_title => substr ($_, 1), fld_type => $order_r {substr $_, 0, 1}}} sort map {join "", $order {uc $_ -> {fld_type}}, $_ -> {fld_title}} @advocates', }; my $limbic = join " " => map {$_ -> {fld_title}} @limbic; my $GRT = join " " => map {$_ -> {fld_title}} @GRT; die "Unequal\n" unless $limbic eq $GRT; __END__ Rate limbic GRT limbic 61.9/s -- -49% GRT 121/s 95% --