Exactly:

/*****/
IP_addr.1 = '10.23.178.200'
IP_addr.2 = '192.168.128.12'
IP_addr.3 = '172.12.210.34'
IP_addr.0 = 3
'PIPE (End ? Name IP_Sort) stem IP_addr.',
'|Spec fs blank ws . pad 0 ',
   'substr w1 of f1 n.3 right',
   'substr w2 of f1 n.3 right',
   'substr w3 of f1 n.3 right',
   'substr w4 of f1 n.3 right',
   '1-* n',
'|Sort 1.12',
'|Spec 13-* n',
'|Cons'
Exit Rc

If the ipaddress isn't at the front of each record you'd of course have to
adjust the field #, and possibly the field separator.
If your input was a spreadsheet saved as a csv for example, with the ip
addresses in column D, you'd use "fs ," and f4.

--
Mike Harding
z/VM System Support

mhard...@us.ibm.com
mike.b.hard...@kp.org
mikehard...@mindless.com
(925) 926-3179 (w)
(925) 323-2070 (c)
IM: VMBearDad (AIM),  mbhcpcvt (Y!)


The IBM z/VM Operating System <IBMVM@LISTSERV.UARK.EDU> wrote on 05/24/2011
08:59:45 AM:

> From: "Schuh, Richard" <rsc...@visa.com>
> To: IBMVM@LISTSERV.UARK.EDU
> Date: 05/24/2011 09:01 AM
> Subject: Re: Sort IP addresses
> Sent by: The IBM z/VM Operating System <IBMVM@LISTSERV.UARK.EDU>
>
> Or, if you are sorting in a pipe, create a separate sort key and
> retain the original unmolested addresses.
>
> Regards,
> Richard Schuh
>
>
>
> > -----Original Message-----
> > From: The IBM z/VM Operating System
> > [mailto:IBMVM@LISTSERV.UARK.EDU] On Behalf Of Alan Altmark
> > Sent: Tuesday, May 24, 2011 8:49 AM
> > To: IBMVM@LISTSERV.UARK.EDU
> > Subject: Re: Sort IP addresses
> >
> > On Tuesday, 05/24/2011 at 11:30 EDT, Dave Jones
> > <d...@vsoft-software.com>
> > wrote:
> > > num1 = right(num1,3,'0')
> > > num2 = right(num2,3,'0')
> > > num3 = right(num3,3,'0')
> > > num4 = right(num4,3,'0')
> > > padded_IP_addr.i = num1 || '.' || num2 || '.' || num3 || '.' || num4
> >
> > That's ok for an intermediate result for sorting, but dogma
> > requires that include "i" in there so that you can relate it
> > back to the original list.
> > A dotted-quad element with leading zeros is traditionally
> > interpreted as octal.
> >
> > Alan Altmark
> >
> > z/VM and Linux on System z Consultant
> > IBM System Lab Services and Training
> > ibm.com/systems/services/labservices
> > office: 607.429.3323
> > mobile; 607.321.7556
> > alan_altm...@us.ibm.com
> > IBM Endicott
> >

Reply via email to