how to sort lines with a $ amount

J. Landman Gay jacque at hyperactivesw.com
Tue Apr 1 05:02:26 CEST 2014


On 3/31/14, 9:03 PM, larry at significantplanet.org wrote:
> I can sort the lines of the field just fine on word 1 (date),  word 2
> (name) and word 3 (number)
>
> But when I try to sort on word 4, I don't know how to get it to come
> out right because the $ in front makes it a string and not a number.

You can sort using a custom function and that's what I'd do here. If the 
values are in field 1, then:

on mouseUp
   sort lines of fld 1 numeric by moneySort(each)
end mouseUp

function moneySort pItem
   if char 1 of pItem = "$" then delete char 1 of pItem
   return pItem
end moneySort

Custom function sorting can do all kinds of clever things. The "each" is 
passed to the function and the sort uses the return value to determine 
the final order.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list