sort question

Ralph R. Forehand ralf at dol.net
Fri Jun 3 14:39:14 EDT 2005


Jack,

1. Open a new stack, place 2 scrolling fields and 1 button "Modify_Sort" on it

2. Copy (cut & paste) your data into fld 1 - must be 1 number/line

3. Copy the following script into your "Midify_Sort" button

on mouseUp  -- by Ralph forehand  06/03/05
  -- inset leading 0s into numers where needed
  put empty into card field 2
  repeat with i = 1 to number of lines in fld 1
    put line i of fld 1 into myNumber
    if char 2 of myNumber ="." then 
    put "0"& myNumber into line i of fld 2
    else
    put myNumber into line i of fld 2
    end if
  end repeat
  
  -- sort modified numbers
  sort cd fld 2
  
  -- Remove leading Zeros returning numbers to original form
  repeat with i = 1 to number of lines in fld 2
    put line i of fld 2 into myNumber
    if char 1 of myNumber = 0 then
      put char 2 to 12 of myNumber into line i of fld 2
    else
      put myNumber into line i of fld 2
    end if
    
  end repeat
end mouseUp

4. Button will put your numbers in the right order.

Trust the above helps and Good Luck,
Ralph

> Greetings,
> 
> I need a field to sort numerically and when I try it I get the result below. I checked the docs and experimented with the numberformat without success. Help!
> 
>jack
>
> 
>
>1.101-
>10.101- 
>10.201-
>10.301.1-
>10.351-
>10.401-
>10.501-
>11.101.1-
>11.151- 
>2.101-
>2.301-
>20.101-
>3.101-
>4.101- 
>4.991-
>5.101.1- 
>5.151-
>5.201-
>5.301-
>5.351.1-
>5.401-
>5.451-
>5.501-
>5.651-
>5.701-
>6.101.1-
>6.201.1-
>6.301-
>6.401.1-
>7.101-
>7.151.1-
>7.201.1-
>7.251-
>7.401-
>7.501.1-
>8.101-
>8.301-
>9.101.1-
>9.351-
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list