Lazarus/FPC has a problem sorting Middle Eastern and other language strings. TComboBox, TListBox, TStringGrid and TStringList. Each control sorts differently. I have a QuickSort routine that works for Hebrew but I do not know if it works for other Middle Eastern Languages. I do not know Arabic Alphabet

if some one could check for other Middle Easter and other languages and let me know, I will send it to FPC for patch if it works. I checked sorting English first and it was OK.
Also it needs to be written better. Too hard to read (I did not write it).
Use 2 TListBox
1 TButton
ListBox1.Sorted:= False (add letters of your Alphabet)
ListBox2.Sorted:= False (empty)
Button1 (OnClick should sort Alphabet and show in ListBox2)
procedure QuickSort(var A: TStringList);
procedure Sort(L, R: Integer);
var
I, J: Integer;
Y, X:string;
begin
I:= L; J:= R; X:= A[(L+R) DIV 2];
repeat
while strIcomp(pchar(A),pchar(X))<0 do inc(I);
while StrIComp(pchar(X),pchar(A[J]))<0 do dec(J);
if I <= J then
begin
Y:= A; A:= A[J]; A[J]:= Y;
inc(I); dec(J);
end;
until I > J;
if L < J then Sort(L,J);
if I < R then Sort(I,R);
end;
begin
Sort(0,A.Count-1);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
StrLst: TStringList;
begin
StrLst:= TStringList.Create;
StrLst.CommaText:= ListBox1.Items.CommaText;
QuickSort(StrLst);
ListBox2.Items.CommaText:= StrLst.CommaText;
FreeAndNil(StrLst);
end;