sort numeric facets with more than 5 values ascending
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 26 May 2010 16:01:43 +0000 (18:01 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 26 May 2010 16:01:43 +0000 (18:01 +0200)
This heuristics allow us to see simple yes/no/maybe lists still as a
count, especially if they are numeric

lib/MojoFacets/Data.pm

index 65aef48..dee9765 100644 (file)
@@ -603,7 +603,8 @@ sub facet {
        my $numeric = $self->_is_numeric($name);
 
        my $sort = $self->param('sort');
-       $sort ||= $numeric ? 'a' : 'c';
+       # sort numeric facets with more than 5 values ascending
+       $sort ||= $numeric && $#facet_names > 4 ? 'a' : 'c';
 
        @facet_names = sort {
                my $result;