Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sort by zip code 1

Status
Not open for further replies.

claudeb

Programmer
Nov 23, 2000
140
CA
hi
i have a file organized in this way:
info1 info2 info3
info4 zip code info5 info6

i need to sort according to the zip code.
what would be the easiest way to do that ?
thanks
claudeb
 
Hi,

If I understand it right, you have two separate records each time and you want to sort the file on information on the second record.

What you can do is read two recors at once in an inputprocedure of a sort. You fill a sortrecord with a prefix with the zipcode and a serialnumber followed by the contents of the original record. On the outputprocedure you can strip off that prefix and write the original record back in the new order you created by this action.

Let us know if this does help you.
 
i am sorry,
i should have been more accurate. from info1 to info6 ,it is one record.and i have several records.
would it be easier to write a program or to use a syncsort utility (if it exists !) ?
thanks
claudeb
 
Using syncsort you can sort this at once giving the position of your sortfields. It depends on if your data is on the same place in every record.

Something like

sort fields=(20,6,,a)

which says something like starting from position 20 over a length of 6 no conversion ascending. But look the exact parm up in the manual or copy some existing example.

Does this help you?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top