Sorting a field

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
EzCoder
Posts: 10
Joined: Sun Sep 30, 2007 12:05 am

Sorting a field

Post by EzCoder » Sun Mar 02, 2008 12:15 am

Hello,
After trying several approaches, I just can't seem to see what I'm doing wrong. The goal is to sort the lines in a certain field by the first Item, then copy the data over into a second field. Copying the data from one field to the other works without problem, so maybe someone can shed some light on what I need to be doing to make the sort work. Here's some sample code:

Code: Select all

on mouseUp
  sort lines of fld "field one" by Item 1
--  repeat for each line thisLine in field "field one"
--    put thisLine &cr after field "field two"
--  end repeat
end mouseUp
Thanks,
EZ

P.S. I've read the documentation and Dan's book enough to confuse myself.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sun Mar 02, 2008 12:20 am

almost there:

Code: Select all

sort field "field one" by item 1 of each
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

EzCoder
Posts: 10
Joined: Sun Sep 30, 2007 12:05 am

Post by EzCoder » Sun Mar 02, 2008 12:24 am

...of each
Aha! ...not I understand the somewhat cryptic error message I kept getting as well. :)

Thank you so much!

EZ

EzCoder
Posts: 10
Joined: Sun Sep 30, 2007 12:05 am

Post by EzCoder » Sun Mar 02, 2008 12:54 am

That works well. :)

Along the same line of thought, other than the available RAM, is there a functional limit to the number of items that can be sorted in such a manner?

I've been testing with sample data ranging from just a few lines to over 5000 and it seems that the larger numbers won't allow the screen to refresh/redraw itself if trying to interact otherwise. (application turns white if you click on anything until it is finished)

Is there a proper way of using "wait with messages" in this situation?

Last set of questions for awhile I think. :?

EZ

Post Reply