'How to use natsort in different language?

I'm trying to sort an array using natsort/natcasesort. But I'm having trouble with non-English (In Turkish) characters. This is the only option that works for me at the moment. How can I overcome this problem? For example, the array looks like this:

   $texts= array("A","Ü","Ç","Ş","Ğ");
    natcasesort($texts);
    echo '<pre>'; print_r($files); echo '</pre>';

Output:

Array
(
    [0] => A
    [2] => Ç
    [1] => Ü
    [4] => Ğ
    [3] => Ş
)


$all_characters = [ "ğ", "Ğ", "ç", "Ç", "ş", "Ş", "ü", "Ü", "ö", "Ö", "ı", "İ" ];
    
$alphabet_all = "AaBbCcÇçDdEeFfGgĞğHhIıİiJjKkLlMmNnOoÖöPpQqRrSsŞşTtUuÜüVvWwXxYyZz";
$small_letters = array("İ","I","Ş","Ğ","Ö","Ü","Ç");
$capital_letters = array("i","ı","ş","ğ","ö","ü","ç");

How should it be ?
A, Ç, Ğ, Ş, Ü



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source