Is it possible to sort a PHP array with a locale setting?
This is the setup:
I am making an interactive sorted list in PHP. By user input, one of a number of categories (columns) can be made to direct the sorting (name, residence, etc). This I worked out by using array_multisort()
function.
Next hurdle. The list is in Swedish and the user will expect Swedish alphabetical order: abcdefghijklmnopqrstuvxyzåäö. Right now the interpreter sorts åäö as non-alphabetical and places them before "a". How to remedy?
I found some scattered info on a setlocale(LC_COLLATE, "sv_SV")
function, but the reviews were not rave and I did not manage to comprehend how it could be used with array_multisort()
. Can it? and if so, how? Is there another way within php?
Thing is, there must be some way – Swedish websites abound where Swedish sort order is applied. Can it be done with php?