Ignore:
Timestamp:
2017-04-03T14:21:18+12:00 (7 years ago)
Author:
kjdon
Message:

added in alpha_numeric_sort - copied from AZlist I think, so if metadata values are numeric, then they will be sorted numerically, ie 10 comes after 9.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/classify/List.pm

    r29094 r31567  
    684684            }
    685685        }       
    686         } 
     686        }
    687687        else {
    688688        # The easier case, just add a partition
     
    968968    }
    969969    else {
    970     return sort(@metadata_values);
    971     }
    972 }
     970    return sort { $self->alpha_numeric_cmp($a,$b) }(@metadata_values);
     971    }
     972}
     973
     974
     975sub alpha_numeric_cmp
     976{
     977    my ($self,$a,$b) = @_;
     978
     979    if ($a =~ m/^(\d+(\.\d+)?)/)
     980    {
     981        my $val_a = $1;
     982        if ($b =~ m/^(\d+(\.\d+)?)/)
     983        {
     984            my $val_b = $1;
     985            if ($val_a != $val_b)
     986            {
     987                return ($val_a <=> $val_b);
     988            }
     989        }
     990    }
     991   
     992    return ($a cmp $b);
     993}
     994
    973995
    974996sub get_metadata_value_display {
Note: See TracChangeset for help on using the changeset viewer.