in reply to Re: Unusual sorting requirements; comparing three implementations.
in thread Unusual sorting requirements; comparing three implementations.
sub x { my @sorted = map $_->[1], sort{ $a->[0] cmp $b->[0] } map[ $_->title eq 'Manager' ? 'A'.$_->name : 'B'.$_->name, $_ ], @employees; }
Faster, but not correct for the original problem. tobyink's Test::More script tested for ->title =~ /Manager/, not for ->title eq 'Manager', and so all those non-generic Manager employees, like the Sales Manager, the Finance Manager, and the Marketing Manager will be sorted as NON-Manager employees. tobyink's benchmark script wrongly reduces the possible titles to "Staff" and "Manager".
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
|
---|
In Section
Meditations