Sorting a list by item [SOLVED]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Sorting a list by item [SOLVED]

Post by atout66 » Fri Apr 04, 2014 2:44 pm

Hi to all,

I want to sort a list. I try to follow the examples of the dictionnary but I must make something wrong :mrgreen:
Here is my code:

Code: Select all

set itemDelimiter to "|" --  each line has 5 items.
   get field "lignesDeResultat" -- The first item is any word like "aWord" , "bWord" , "cWord", etc.
   sort IT ascending international by item 1 of field "lignesDeResultat"
   put IT into  fld "lignesDeResultat"
I have no syntax error but the fld "lignesDeResultat" doesn't update either !!!
Any idea around ?

Kind regards.
Last edited by atout66 on Fri Apr 04, 2014 3:50 pm, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Sorting a list by item

Post by atout66 » Fri Apr 04, 2014 3:05 pm

I notice one mistake in the code when I wrote

Code: Select all

set itemDelimiter to "|"
instead of

Code: Select all

set the itemDelimiter to "|"
but this changes nothing...
Also, the checkboxe <Don't wrap> and <Lock text> of the field "lignesDeResultat" are unchecked.
Discovering LiveCode Community 6.5.2.

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Sorting a list by item

Post by Thierry » Fri Apr 04, 2014 3:15 pm

atout66 wrote:Hi to all,

I want to sort a list. I try to follow the examples of the dictionnary but I must make something wrong :mrgreen:
Here is my code:

Code: Select all

set itemDelimiter to "|" --  each line has 5 items.
   get field "lignesDeResultat"
   sort IT ascending international by item 1 of field "lignesDeResultat"
  -------------------------------------------^^^^^^   of  IT  ^^^^^^^^^
   put IT into  fld "lignesDeResultat"
Does this help?

By the way, what does ascending international?
I don't see it in the dictionary..

Regards,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Sorting a list by item

Post by dunbarx » Fri Apr 04, 2014 3:31 pm

Hi.

I think you want:

Code: Select all

 sort IT ascending international by item 1 of each
The sort command in this construction form needs a sortKey that is referenced within the data to be sorted. You can use what you had, but the sortKey is then a single external reference, and not based on the text itself. I would be surprised if it sorted at all, though it would likely not throw an error.

Craig

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Sorting a list by item

Post by atout66 » Fri Apr 04, 2014 3:45 pm

By the way, what does ascending international?
I don't see it in the dictionary..
Euh... I found it somewhere, in a lesson surely, don't remember.
It allows to sort letters with accent like "é" , "à" , etc., in french or other languages with that kind of letters.
So you get word starting with an "e" and if you don't 'ask' the "international", the next word will be starting with an "f" (if so), skipping a word like "éléphant" which would be placed at the end of the list.
I'm not sure to be so clear at all, but I really don't remember where i saw that. :shock:
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sorting a list by item

Post by Klaus » Fri Apr 04, 2014 3:47 pm

Bonjour atout66,

as Craig wrote! :D

General hint: Do not use IT more than once or at all if not neccessary, use a variable insead!
IT will change when you least exspect IT 8)
...
set itemDelimiter to "|" -- each line has 5 items.
put field "lignesDeResultat" into tText
sort lines of tText ascending international by item 1 of each
put tText into fld "lignesDeResultat"
...

Best

Klaus

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Sorting a list by item

Post by atout66 » Fri Apr 04, 2014 3:49 pm

Craig, I'm glad to tell you that you can be surprised by yourself with no limit :lol:
Your script works perfectly !

Thanks to all of you.
Discovering LiveCode Community 6.5.2.

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Sorting a list by item

Post by Thierry » Fri Apr 04, 2014 4:01 pm

atout66 wrote:
By the way, what does ascending international?
I don't see it in the dictionary..
Euh... I found it somewhere, in a lesson surely, don't remember.
It allows to sort letters with accent like "é" , "à" , etc.,
Merci and sorry for the wrong input above :)

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Post Reply