[OPEN-ILS-DEV] LC Sort

Jason Etheridge jason at esilibrary.com
Sun Nov 23 22:32:17 EST 2008


> Well, there's the question of how to compare call numbers from
> different schemes.  Picking one and sorting on that would be easy.
> Making that configurable so you can choose exactly one out of several
> potential schemes per Evergreen instance is possible.  Dewey, LC and
> SUDOC inter-sorted together?  Not so much...  Thus, ASCIIbetical it
> remains.

Okay folks, if this is dumb, be gentle. :)

I think any sort algorithm is going to need to deal with input that
doesn't match the scheme (does it automatically come before or after
all values within the scheme?), and once you're doing that, you could
just start nesting sort algorithms, and have some way to dictate the
order in which it happens.

So maybe you want to configure your Evergreen to do something like this:

Sort #1 -> LCCN
Sort #2 -> DDS
Sort #3 -> Default / ASCIIbetically

And when constructing the sort functions, you define an extra argument like so:

sort[1] = function lccn_sort(a,b,n) {

    if ( not_lccn(a) and not_lccn(b) ) return sort[n](a,b,n+1);

    if ( not_lccn(a) ) return -1;
    if ( not_lccn(b) ) return 1;

    # do my normal LCCN comparisons
    ...
};

sort[2] = function dds_sort(a,b,n) {

    if ( not_dds(a) and not_dds(b) ) then sort[n](a,b,n+1);

    if ( not_dds(a) ) return -1;
    if ( not_dds(b) ) return 1;

    # do my normal DDS comparisons
    ...
}

sort[3] = function default_sort(a,b,n) {

   return a <=> b;

}

-- 
Jason Etheridge
 | VP, Community Support and Advocacy
 | Equinox Software, Inc. / The Evergreen Experts
 | phone:  1-877-OPEN-ILS (673-6457)
 | email:  jason at esilibrary.com
 | web:  http://www.esilibrary.com


More information about the Open-ils-dev mailing list