I'd be tempted to loop through the array and convert to English characters before sorting. E.g.
<?php
$array = array('Borgloon','Thuin','Lennik','Éghezée','Aubel');
setlocale(LC_CTYPE, 'nl_BE.utf8');
$newarray = array();
foreach($array as $k => $v) {
$newarray[$k] = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $v);
}
sort($newarray);
print_r($newarray);
?>
Probably not the best in terms of processing speed/resources used. But sure does make it easier to understand the code.
Edit:
Thinking about it now, you might be better using some kind of lookup table, something like this:
<?php
$accentedCharacters = array ( 'à', 'á', 'â', 'ã', 'ä', 'å', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Š', 'Ž', 'š', 'ž', 'Ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý' );
$replacementCharacters = array ( 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'S', 'Z', 's', 'z', 'Y', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y' );
$array = array('Borgloon','Thuin','Lennik','Éghezée','Aubel');
$newarray = array();
foreach($array as $k => $v) {
$newarray[$k] = str_replace($accentedCharacters,$replacementCharacters,$v);
}
sort($newarray);
print_r($newarray);
?>
natcasesort
doesn't work out of the box: codepad.org/QgdF5DUY – Typehigh