sorting zip codes

Jim Hurley jhurley at infostations.com
Sun Jul 10 19:45:40 EDT 2005


>
>Message: 5
>Date: Sun, 10 Jul 2005 11:52:48 -0700
>From: Rich Lague <laguer at ucs.orst.edu>
>Subject: sorting zip codes
>To: How to use Revolution <use-revolution at lists.runrev.com>
>Message-ID: <CF391722-F173-11D9-A4E4-000393A7F528 at ucs.orst.edu>
>Content-Type: text/plain;	charset=WINDOWS-1252;	format=flowed
>
>Iím trying to set up a sort of a stack of address cards by zip code.
>Some of the zips are only the first 5 numbers and some of them are in
>the form ìxxxxx-xxxxî.
>
>The script, ìsort cards numeric by field "zip"ì sorts all the 9 number
>zips first, then sorts the 5 number zips-- not what I want.
>
>I tried ìsort cards of this stack numeric by chars 1 to 5 of field
>ìzipîî I go a ìbad factorî error.
>
>Then I tried ìsort cards of this stack numeric by first 5 chars of
>field ìzipîî Another ìbad factorî.
>
>I also tried, ìsort cards of this stack numeric by (chars 1 to 5 of
>field "zip")î -- Bad factor still.
>
>Is there a way?
>
>Thanks,
>
>Rich
>
>**********************************************


Rich,

Maybe not the best but this works for me.  Our 
neighborhood assoc. has a similar mailing list.

1) Let the database be in field "originalDB"
2) Assume the variable zip codes are the last 
item, say item 6 item in each line of the DB, 
with some like formatted xxxxx-xxxx and some just 
xxxxx.
3) Create two new items, numbers 7 and 8. Put the 
xxxxx into item 7 and xxxx into item 8
4) Sort the new list first by item 8 and then by 
item 7 and put the results into field "final"
5) If you like you can delete items 7 and 8 at this point.

on mouseUp
   put field "originalDB" into tList
   set itemdel to tab
   repeat for each line tLine in tList
     put item 6 of tLine into tZip
     set itemdel to "-"
     put tLine & tab & item 1 of tZip & tab & item 2 of tZip & cr after results
     set itemdel to tab
   end repeat
   sort lines of  results by item 8 of each
   sort lines  of results by item 7 of each
   put results into field "final"
end mouseUp

Jim



More information about the use-livecode mailing list