[pmwiki-users] pagelist sort - accented characters

Petko Yotov 5ko at 5ko.fr
Sat May 23 07:59:57 CDT 2009

On Thursday 21 May 2009 21:15:04 Christophe David wrote:
> Would somebody have an idea how to get pagelists sorted according to a
> "dictionary order" with accented characters ?
> I created a simple example on http://www.pmwiki.org/wiki/TestSort/TestSort
> The pagelist lists four pages, named Ad, Ae, Aé (e with acute accent), Af
> I would like to obtain Ad, Ae, Aé, Af, and not Ad, Ae, Af, Aé .

You need to define a custom sort function. That's what I placed in 
TestSort.TestSort.php :

  $PageListSortCmp['namelocalesort'] = 'LocaleSort($x, $y)';
  function LocaleSort($a, $b)
    $x = array($a, $b);
    setlocale(LC_ALL, 'fr_FR');
    sort($x, SORT_LOCALE_STRING);
    return ($x[0]==$a)? -1:1;

You can add this code to your config.php, and then in the wiki page, 
use "(:pagelist order=namelocalesort:)". 

The line "setlocale(...)" may be  not required for your wiki.


More information about the pmwiki-users mailing list