Sort

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Sort

Post by Nakia » Wed May 01, 2013 9:24 am

Hi,
I need to sort a chuck of Tab delimted text decending by item 4 of each.
I have this below statement and it works BUT occasionally the value in item 4 of each will conatin a Negative number (Like below) and I want the sort to ignore that "-".

My Sort is
sort lines of tRacTen descending numeric by item 4 of each
Example if tRacTen
APX01520 2013-04-11 16:48:13 1 21686.0 17 228729.77 6609636.0 293.12
APX01520 2013-04-11 16:46:52 1 21109.0 21 228673.08 6609979.5 276.76
APX01520 2013-04-11 12:27:02 1 18084.0 15 228741.69 6609679.5 286.39
APX01520 2013-04-14 13:27:00 1 -18226.0 14 228177.78 6610446.5 254.99
APX01520 2013-04-14 07:43:24 1 -18267.0 14 228165.05 6610434.0 247.6
APX01520 2013-04-14 06:36:32 1 -18886.0 15 228515.87 6609596.0 297.47
APX01520 2013-04-13 04:09:01 1 -19675.0 17 228136.84 6610210.5 265.43

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Sort

Post by bn » Wed May 01, 2013 9:48 am

Hi Nakia,

try

Code: Select all

sort tRacTen descending numeric by abs(item 4 of each)
Kind regards
Bernd

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Sort

Post by Dixie » Wed May 01, 2013 9:52 am

Nakia...

Code: Select all

on mouseUp
   set itemdel to tab
   sort lines of fld 1  ascending numeric by ABS(item 4 of each)
end mouseUp
Dixie

Edit : Bernd... too quick for me.. :D

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Sort

Post by Nakia » Thu May 02, 2013 4:14 am

Ahhh, Absolute....You know, I remembered using this before but for the life of me couldn't remember what is what called :oops:

Post Reply