Sorting French Characters ?

Currently I am using a Listbox and using the built in Sort method which works for standard Roman characters. However I got a client who is French speaking and it appears that all the accented text are placed at the back of list instead of being treated as proper characters.

In my CompareRows Event Handler. I had it set to

[code]Dim s1 As String = DefineEncoding(Me.Cell(row1,column),encodings.DOSCanadianFrench)
Dim s2 As String = DefineEncoding(Me.cell(row2,column),encodings.DOSCanadianFrench)
Dim v1 As Double = CDbl(s1)
Dim v2 As Double = CDbl(s2)
If v2<>v1 Then
Result = Sign(v2-v1)
Return True
Elseif s1 <> s2 Then
Result = StrComp(s1,s2,0)

Return True
End If
Return False[/code]

I tried encoding using UTF8, UTF16, UTF32 and setting the StrComp mode between 1 and 0 and it still comes out the same.

I am using the Mac version of Xojo 2019 1.1

Thanks

This might work

[code]Dim s1 As String = DefineEncoding(Me.Cell(row1,column),encodings.DOSCanadianFrench)
Dim s2 As String = DefineEncoding(Me.cell(row2,column),encodings.DOSCanadianFrench)
Dim v1 As Double = CDbl(s1)
Dim v2 As Double = CDbl(s2)
If v2<>v1 Then
Result = Sign(v2-v1)
Return True
Elseif s1 <> s2 Then
s1 = ConvertEncoding(Lowercase(s1), Encodings.ASCII)
s2 = ConvertEncoding(Lowercase(s2), Encodings.ASCII)
Result = StrComp(s1,s2,0)

Return True
End If
Return False[/code]

This statement is wrong. Read the Listbox entry in the LR to get a correct explanation.

If, in your list, you have entries that starts with 0 thru 9 values, you will get a bad sort too.
Imagine the client with a lot of file whose names starts with 1, 2, 10, 100, 1000 and saw a sort different (1, 10, 100, 1000, 2) than what (s)he sees in the Finder (1, 2, 10, 100, 1000) !

In short: this is not a matter of French: you will get the same with German, Italian, Spanish,and even in English (providing you use non ASCII and/or numeric values as text).

Life can be complicated.

Thank you Jeremie so much, it worked. Just got my customer to confirm the sort.

I just had to remove the DefineEncoding codes

[quote=453303:@Emile Schwarz]This statement is wrong. Read the Listbox entry in the LR to get a correct explanation.

If, in your list, you have entries that starts with 0 thru 9 values, you will get a bad sort too.
Imagine the client with a lot of file whose names starts with 1, 2, 10, 100, 1000 and saw a sort different (1, 10, 100, 1000, 2) than what (s)he sees in the Finder (1, 2, 10, 100, 1000) !

In short: this is not a matter of French: you will get the same with German, Italian, Spanish,and even in English (providing you use non ASCII and/or numeric values as text).

Life can be complicated.[/quote]

Emile, I actually got the numeric sort part handled earlier but didn’t want to complicate the code here and just took this code sample just to settle the sorting with accent.

Thank you for your concern.