non-filing article sorting (php)

From: Kevin Kierans <kevink_at_nyob>
Date: Wed, 14 Dec 2005 11:48:49 -0800
To: CODE4LIB_at_listserv.nd.edu
Found this on the web, which I can work with, but
does anyone have a complete non-filing article
(English only) routine ready to go?

Should be able to add "a " and "an " , and the function below should work
right?

kevin
=====================

a quick function to point uksort() at, for sorting by key, but ignoring
"the" from any keys that start with it:

<?php
function comp($a,$b)
{
   //remove "the" (case-insensitive), and any non-word
   // characters from any string(s) that start with "the"
   $a = preg_replace('|^the\b\W*|i','',$a);
   $b = preg_replace('|^the\b\W*|i','',$b);

   if ($a == $b) {
       return 0;
   }
   return ($a > $b) ? 1 : -1;
}
?>
Received on Wed Dec 14 2005 - 14:56:35 EST