[pmwiki-users] pagelist sort using locale
rogutes at googlemail.com
Fri Feb 6 07:15:49 CST 2009
Christophe David (2009-02-06 10:42):
> When sorting pagelists, for example with the option "order=title",
> the sort does not take in account locale settiings.
> This causes the french accented 'a' ('à' or 'â' ) to be listed after 'z'.
> The PHP sort function allows a second parameter (bool sort ( array
> &$array [, int $sort_flags=SORT_REGULAR ] )) which can be set to
> Is there a way to tell PmWiki to use this mode when sorting, without
> programming a dedicated function (CustomPagelistSortOrder) ?
Currently, pagelist ordering seems to be determined by doing a case
insensitive comparison of strings with the PHP function strcasecmp().
This function doesn't really work out of ASCII, but PHP manual says it
is binary safe (I guess this means that it is safe to use with
differently encoded strings).
On the other hand, PHP has a strcoll() function, which is able to do
locale based string comparison, but it is not binary safe and is case
So, if you're already using UTF-8, there should be no problems with the
following line. But if you're not, problems might arise later on
(but don't take my words for granted - I am not well versed in this
Also, you are supposed to loose case insensitivity with this, but
$PageListSortCmp['title'] = "strcoll(\$PCache[\$x]['title'],\$PCache[\$y]['title']);";
-- Rogutės Sparnuotos
More information about the pmwiki-users