my $cnt_sort = 0; my $cnt_sort_schwartz = 0; my $cnt_cmp_sort = 0; my $cnt_cmp_sort_schwartz = 0; my @array = ( [25,1], [3,7], [1,2], [2,4], [2,2], [35,34], ); # Native my @dummy = sort{ $cnt_cmp_sort++; helper($a) <=> helper($b) }@array ; # nach Schwartz my @dummy_schwartz = map{$_->[0]} sort{$cnt_cmp_sort_schwartz++; $a->[1] <=> $b->[1] } map{[$_, helper_schwartz($_)]} @array; print "Anzahl der Helper-Aufrufe cnt_sort: $cnt_sort\n"; print "Anzahl der Helper-Aufrufe cnt_sort_schwartz: $cnt_sort_schwartz\n"; print "Anzahl der Vergleiche cnt_cmp_sort: $cnt_cmp_sort\n"; print "Anzahl der Vergleiche cnt_cmp_sort_schwartz: $cnt_cmp_sort_schwartz\n"; sub helper{ my $ref = shift; $cnt_sort++; return abs($ref->[1] - $ref->[0]); } sub helper_schwartz{ my $ref = shift; $cnt_sort_schwartz++; return abs($ref->[1] - $ref->[0]); }