Array sorting but without articles

Sometimes you want to sort an array in PHP, but exclude certain words.
I once needed this to sort a list of artists and bands. It is very common for bandnames to have articles in front of them.
When sorting those, it feels more natural to leave those words out, so that “The Doors” would end up at the letter D, and not T.
This little PHP function will do natcasesort, but will leave out the english articles a, an, the, and the dutch articles de, het and een:

function sort_na($a, $prefix= '/^((d|th)e|an?|een|het)s*/i') {
    foreach($a as $entry){
    $cmp=create_function('$x, $y',
        'return strnatcasecmp($x["name"], $y["name"]);');
    usort($b, $cmp);
    foreach($b as $entry) {
    return $c;


  1. Where did you get this wp template? I’ve been looking the whole day for something like this but I’m about to give up :((sorry, I know it’s not really on topic)RegardsNaida

Leave a comment

Your email address will not be published. Required fields are marked *