I have an initial array with names and ID-s that have to be sorted, based on family names while following the local alphabet:
$names = array(
    "134" =>    "Mati Vänt",
    "24" =>     "Mati Vint",
    "11" =>     "Mati Wint",
    "12" =>     "John Zareem",
);
and the function to sort them (big thanks to Alma Do):
setlocale(LC_ALL, 'et_EE.utf8');
uasort($nimed, function($x, $y)
{
    return strcoll(
    end(preg_split('/\s+/', $x)),
    end(preg_split('/\s+/', $y))
);
});
Which gives the result: John Zareem, Mati Vint, Mati Wint, Mati Vänt.
It is correct in the sense that Z comes before V like in the local alphabet, but why are family names starting with one letter (V) mixed with names with a different first letter (W)? Is there perhaps a way to avoid it? Thanks in advance!