Numeric sorting problem
Mark Smith
mark at maseurope.net
Sat Mar 12 12:55:36 EST 2005
On 12 Mar 2005, at 16:27, Karen wrote:
> 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?
Try sorting on words rather than items. One possible gotcha is that the
shares might have multi-word names, but since stock data usually has
the numbers at the end of the line you could use the negative word
numbers ie. sort lines of fld "List Stocks" numeric by word -1 of each.
Also, if your lists get quite long, you might get a speed improvement
by putting the field into a variable, sorting the variable and then
putting it back into the field. In general, direct operations on fields
tend to be much slower than operations on variables.
Cheers,
Mark
More information about the use-livecode
mailing list