Numeric sorting problem
Karen
Karen at curlypaws.com
Sat Mar 12 07:29:36 EST 2005
Hi,
I'm trying to sort a container which is a scrolling list field, populated
with HTML text items separated by tabs. The typical format would be:
(Name) (Ticker) (Price) (No.) (Value)
Share 1 BARC.L 484.00 100 484.00
Share 2 RSA.L 85.79 1000 850.79
Column 1 is the alphabetic name of the stock, and I can sort the list quite
happily by setting the item delimiter to tab and doing:
sort lines of field "List Stocks" ascending text by item 1 of each
However, if I try to sort using the fifth column (the value of the stock
holding) by using the command:
sort lines of field "List Stocks" descending numeric by item 5 of each
Then nothing happens, the sort order remains unchanged. I've been trying
various hacks, but all with no result - I can't get it to sort on the
numeric fields.
I'm a bit stumped as to why this isn't working, but it may be impacted by
the fact that the numeric fields are formatted using a statement such as:
put format("%8.2f",tField) into tField
Before being put into the lines, to ensure that they line up correctly.
Could the leading spaces affect the sort?
Am I doing something really silly here? Any help would be very gratefully
received!
As an aside, is there a better way of sorting these items using Revolution?
What I currently do is read from my file and populate the field. Then, when
a sort is requested, I sort the field and then use the sorted lines from it
to write out to my file again (to ensure that the file and the display order
remain in step).
Thanks,
Karen
More information about the use-livecode
mailing list