From: Dobrica Pavlinusic Date: Thu, 15 Apr 2010 18:19:16 +0000 (+0200) Subject: no warnings for non-numeric X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;ds=sidebyside;h=796df13e49a6ca1be8fb4ce2edc54b325aa5c800;p=MojoFacets.git no warnings for non-numeric --- diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index 0c57201..c5a8b8a 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -213,9 +213,11 @@ sub table { # FIXME - multi-level sort my $numeric = $self->_is_numeric($order); + my $missing = $numeric ? 0 : ''; + no warnings qw(numeric); my @sorted = sort { - my $v1 = exists $a->{$order} ? join('', @{$a->{$order}}) : ''; - my $v2 = exists $b->{$order} ? join('', @{$b->{$order}}) : ''; + my $v1 = exists $a->{$order} ? join('', @{$a->{$order}}) : $missing; + my $v2 = exists $b->{$order} ? join('', @{$b->{$order}}) : $missing; ($v1,$v2) = ($v2,$v1) if $sort eq 'd'; $numeric ? $v1 <=> $v2 : $v1 cmp $v2 ; } $self->_data_items;