[Koha-devel] Table sorting and articles

Owen Leonard oleonard at myacpl.org
Wed Apr 2 17:24:25 CEST 2008


I've been adding a javascript-based table sorter to many tables in the
3.0 staff client and OPAC. It's a jquery plugin
(http://tablesorter.com), and allows one to set custom parsers for
dealing with specialized kinds of data. I implemented a special parser
for English-language articles, so that titles could be ordered
correctly while ignoring "a," "an," and "the."

$.tablesorter.addParser({
    id: 'articles',
    is: function(s) {return false;  },
    format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); },
    type: 'text'
});

I'm hoping the same can be done for other languages by implementing a
system preference that contains the articles ("the|an|a") in the
script above. I'm a little concerned about how well Javascript will
handle non-English or non-Western characters, but I don't have the
right data to test. Some searching turned up the statement, "The
default sort algorithm in JavaScript is based purely on the Unicode
code point." Which would indicate that as long as Unicode orders
things correctly JavaScript will too. I'm not sure this is the case.

I'd like to get some feedback. Does this sound workable for other
languages? Can anyone run some tests with some "exotic" data?

Thanks,

 Owen

-- 
Web Developer
Athens County Public Libraries
http://www.myacpl.org



More information about the Koha-devel mailing list