Sorting Trouble

Jim Ault JimAultWins at yahoo.com
Thu Jul 5 17:54:30 EDT 2007


On 7/5/07 2:26 PM, "Blair Morrissey" <blairmorrissey at mac.com> wrote:

> THE PROBLEM:
> When the line and item delimiters are respectively '|' and tab,
> I cannot get either of the following to work as I want:
> 
> sort lines of kdata ascending numeric by last item of each
> 
> sort lines of fld "f3" ascending numeric by last item of each
> 
> I have the script check (prior to the above) that the last
> item of each line is numeric.
> 
> Other uses of kdata using the non-standard delimiters work well.

I believe the answer to your particular task is:

SORT considers lines to always be cr delimited
as well as the FILTER command.

thus the lineDelimiter setting does not affect them.


First: are there any returns in kdata?
If not, then do the following:

put  kdata into specialK
replace "|" with cr in specialK
set the itemDel to tab
sort specialK numeric by item -1 of each

replace cr with "|" in specialK
breakpoint  -- see if this does the right job
--then
put specialK into kdata
------------------------------------
If there are cr's in kdata (although this does not make much sense to me)
then you could try:

put  kdata into specialK
replace cr with "^" in specialK
replace "|" with cr in specialK
set the itemDel to tab
sort specialK numeric by item -1 of each

replace "^" with cr in specialK
put specialK into kdata

If you find that the lineDel can be used, then I would like to add this to
my knowledge base.

Jim Ault
Las Vegas






More information about the Use-livecode mailing list