Page 1 of 1

How sorts accented characters?

Posted: Mon Jul 16, 2012 8:05 am
by Partenaire
Hello,

I would like sort a field with accented characters.

sort lines of fld "xx" ascending work but all accented letters are on the end
a
è
e
é
p

result :
a
e
p
é
è

and i would
a
e
é
è
p

Thanks for yours help

Re: How sorts accented characters?

Posted: Mon Jul 16, 2012 9:34 am
by LittleGreyMan
Salut,

The Dictionary is not really clear on this point, but it seems you can use an international sortType:
Dictionary wrote:The sort international form is like sort text, except that it sorts accented characters together with their unaccented counterparts. For example, "" sorts between "e" and "f", rather than at the end of the alphabet as it would using the sort text form.
Not tested.

HTH

Re: How sorts accented characters?

Posted: Mon Jul 16, 2012 11:39 am
by jmburnod
Salut,

This script work, but i,m sur there is a simplest way

Code: Select all

on debSortFieldWithAccent
   put fld 1 into t
   put t into t2
   put "éèêàâä" into tLesC
   put "eeeaaa" into tLesC2
   repeat for each char tChar in tLesC
      put char offset(tChar,tLesC) of tLesC2 into tNewc
      replace tChar with tNewc in t2
   end repeat
   put the num of lines of t into nbl
   repeat with i = 1 to nbl
      put line i of t into tChar
      put "," &  line i of t2 after line i of t
      wait 1 milliseconds
   end repeat
   sort lines of t by item 2 of each
   repeat with z= 1 to nbl
      delete item 2 of line z of t
      wait 1 milliseconds
   end repeat
   put t
end debSortFieldWithAccent
Best regards

Jean-Marc

Re: How sorts accented characters?

Posted: Mon Jul 16, 2012 12:43 pm
by LittleGreyMan
If you don't mind getting the accented chars before standard ones,

Code: Select all

sort lines of fld 1 international
works. Here's the result of a quick test:

à
assembler
édifice
effeuiller
fontaine
hérétique
Hérisson
herse

If it doesn't suits you, you'll have to manage your own script, as Jean-Marc suggested.

Re: How sorts accented characters?

Posted: Mon Jul 16, 2012 1:21 pm
by Partenaire
Hi and Thank you

Sort the field international work and using descending or ascending work again.

Thank you Jean Marc for your code, maybe i use it into and other need.

Warms regards

Re: How sorts accented characters?

Posted: Mon Jul 16, 2012 3:03 pm
by jmburnod
Yes,
It seem more simple :oops:

Best regards

Jean-Marc

Re: How sorts accented characters?

Posted: Sat Apr 06, 2013 1:42 pm
by snm
As I read previous messages in this thread it should work. Was something changed in LC 5.5.4 or I missed something in code:

Code: Select all

sort lines of fld "names" international
doesn't work properly. It's behaviour is the same as without "international" sortType.

Marek

Re: How sorts accented characters?

Posted: Tue Apr 09, 2013 1:22 pm
by snm
Anybody could help me with this problem?

Marek

Re: How sorts accented characters?

Posted: Tue Apr 09, 2013 2:13 pm
by bn
Hi Marek,

could you post a stack or a list of accented words you would like to have sorted?
It would be easier to help you.

In my testing international sort works for a lot of accented characters pre and post 5.5.4

Kind regards
Bernd

Re: How sorts accented characters?

Posted: Tue Apr 09, 2013 2:51 pm
by snm
Hi Bernd,

Thanks a lot for reply. Zipped stack file attached.
After proper sort names starting with "Łukasz" should go after names "Ludwik".
Button "Sort" is working as sort / unsort.

Marek

Re: How sorts accented characters?

Posted: Tue Apr 09, 2013 7:28 pm
by bn
Hi Marek,

I see the same you are seeing.

I don't know why it does what it does, but it does it for all versions of Livecode I tested.

I think that sort international refers to the high ASCII values (greater 127 up to 255). The sort works on the ascii values of characters. If you use "international" then the higher ascii values of e.g. é is correctly sorted after e.
But Ł seems to be outside of the ASCII range (the html value is Ł) This is probably why it fails to sort.

I hope someone who knows more about Unicode will jump in.
Sorry to be of no help.

Kind regards
Bernd

Re: How sorts accented characters?

Posted: Tue Apr 09, 2013 7:37 pm
by snm
Thanks a lot Bernd for explanation, I was worry that reason of problems with unicode sorting is like you described.

Marek

Re: How sorts accented characters?

Posted: Wed Nov 06, 2013 2:38 pm
by speakupBUSNJcY
Could this be done with a shell command? I assume UNIX can handle sorting unicode characters.