Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SORT DUPLICATES

78 views
Skip to first unread message

Roger While

unread,
Apr 13, 2007, 3:03:10 PM4/13/07
to
Is there any implemenation that does not do
that per default ?


Howard Brazee

unread,
Apr 13, 2007, 3:53:31 PM4/13/07
to
On Fri, 13 Apr 2007 21:03:10 +0200, "Roger While" <si...@sim-basis.de>
wrote:

>Is there any implemenation that does not do
>that per default ?

I don't know what you are asking. Could you give us an example?

William M. Klein

unread,
Apr 13, 2007, 4:24:30 PM4/13/07
to
If by this question you mean "are there any implementations that do NOT keep
duplicates in order during a SORT", then the answer is DEFINITELY "yes" there
are some.

Depending upon the "type of sort" used, the order that records come in and the
order they go out in (when DUPLICATES is not specified) may have
zero-to-complete correspondence.

Again, depending upon the type of sort used, there may be a "reasonable" amount
of overhead in GUARANTEEING that duplicates are retained in their "original"
order.

--
Bill Klein
wmklein <at> ix.netcom.com
"Roger While" <si...@sim-basis.de> wrote in message
news:evok5f$gu$00$1...@news.t-online.com...

Rick Smith

unread,
Apr 13, 2007, 7:00:52 PM4/13/07
to

"Roger While" <si...@sim-basis.de> wrote in message
news:evok5f$gu$00$1...@news.t-online.com...
> Is there any implemenation that does not do
> that per default ?

Micro Focus COBOL 3.2.24 when sorting a table;
but apparently not when sorting a file.

Alistair

unread,
Apr 14, 2007, 4:32:47 PM4/14/07
to
On 13 Apr, 20:03, "Roger While" <s...@sim-basis.de> wrote:
> Is there any implemenation that does not do
> that per default ?

Both CA-Sort and Dfsort allow various options with duplicate records:
deletion of duplicates; summation into one record; retention of sort
input sequence upon output.

Robert Jones

unread,
Apr 14, 2007, 5:34:06 PM4/14/07
to
On Apr 13, 8:03 pm, "Roger While" <s...@sim-basis.de> wrote:
> Is there any implemenation that does not do
> that per default ?

The implementations I have seen all provide that as an option, with
the default being not to do so. As Bill Klein says, whether or not it
happens depends on the sort algorithm used. An implementor might use
several in one package and automatically select the one that seems
most appropriate for the volume and characteristics of the data. As
far as COBOL is concerned, the sequence of duplicate keys is
undefined, as I believe is the case for most sort utilities.

What would you expect or want when sorting several concatenated files
which each may or may not have duplicate records?

Robert

William M. Klein

unread,
Apr 14, 2007, 8:18:07 PM4/14/07
to
Alistair,
Can you "invoke" any of the options other than duplicates or no duplicates in
order, from a COBOL internal sort? I know that there are SOME DFSort
(SyncSort) options that you can "sort-of" request for a specific COBOL internal
SORT, but certainly the delete duplicates (for example) is NOT one that I think
you can request directly. You would need to do an OUTPUT procedure to do this.

--
Bill Klein
wmklein <at> ix.netcom.com

"Alistair" <alis...@ld50macca.demon.co.uk> wrote in message
news:1176582767.7...@p77g2000hsh.googlegroups.com...

Robert Jones

unread,
Apr 15, 2007, 6:48:51 AM4/15/07
to
On Apr 15, 1:18 am, "William M. Klein" <wmkl...@nospam.netcom.com>
wrote:

> Alistair,
> Can you "invoke" any of the options other than duplicates or no duplicates in
> order, from a COBOL internal sort? I know that there are SOME DFSort
> (SyncSort) options that you can "sort-of" request for a specific COBOL internal
> SORT, but certainly the delete duplicates (for example) is NOT one that I think
> you can request directly. You would need to do an OUTPUT procedure to do this.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com"Alistair" <alist...@ld50macca.demon.co.uk> wrote in message

>
> news:1176582767.7...@p77g2000hsh.googlegroups.com...
>
> > On 13 Apr, 20:03, "Roger While" <s...@sim-basis.de> wrote:
> >> Is there any implemenation that does not do
> >> that per default ?
>
> > Both CA-Sort and Dfsort allow various options with duplicate records:
> > deletion of duplicates; summation into one record; retention of sort
> > input sequence upon output.

Bill and Alistair,

It is a long time since I used them, but I think DFSORT and SYNCSORT
are they the same now?) allowed the use of a SORTCNTL dd statement in
which to specify all manner of SORT options that COBOL itself does not
facilitate. Not a COBOL solution, but may still be of use.

Robert

Alistair

unread,
Apr 15, 2007, 11:21:05 AM4/15/07
to
On 15 Apr, 01:18, "William M. Klein" <wmkl...@nospam.netcom.com>
wrote:

> Alistair,
> Can you "invoke" any of the options other than duplicates or no duplicates in
> order, from a COBOL internal sort? I know that there are SOME DFSort
> (SyncSort) options that you can "sort-of" request for a specific COBOL internal
> SORT, but certainly the delete duplicates (for example) is NOT one that I think
> you can request directly. You would need to do an OUTPUT procedure to do this.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com"Alistair" <alist...@ld50macca.demon.co.uk> wrote in message

>
> news:1176582767.7...@p77g2000hsh.googlegroups.com...
>
>
>
> > On 13 Apr, 20:03, "Roger While" <s...@sim-basis.de> wrote:
> >> Is there any implemenation that does not do
> >> that per default ?
>
> > Both CA-Sort and Dfsort allow various options with duplicate records:
> > deletion of duplicates; summation into one record; retention of sort
> > input sequence upon output.- Hide quoted text -
>
> - Show quoted text -

My memory is porous and it is a long time since I last used mainframe
sorts. So the cop-out is that I don't know (I can not even recall how
the internal sorts are controlled).

William M. Klein

unread,
Apr 15, 2007, 12:07:17 PM4/15/07
to
I found a reference in the COBOL documentation (talking about IGZSRTCD and
SORTCNTL) that talked about putting DFSort options in those datasets. It talks
about "some restrictions" but I couldn't find exactly WHICH options are and are
not valid.

the statement at:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/igy3pg32/1.12.15.1

that says,

"
The control statements that you can include in IGZSRTCD (in the order listed)
are:

1. SMS=nnnnn, where nnnnn is the length in bytes of the most frequently
occurring record size. (Use only if the SD file is variable length.)

2. OPTION (except keywords SORTIN or SORTOUT).

3. Other DFSORT control statements (except SORT, MERGE, RECORD, or END). "

seems BROADER than I remembered, but maybe it is correct and current and that
only those last 4 specific statements are prohibited.


--
Bill Klein
wmklein <at> ix.netcom.com

"Robert Jones" <rjo...@hotmail.com> wrote in message
news:1176634131.3...@o5g2000hsb.googlegroups.com...

Charles Hottel

unread,
Apr 15, 2007, 12:07:32 PM4/15/07
to

"Roger While" <si...@sim-basis.de> wrote in message
news:evok5f$gu$00$1...@news.t-online.com...
> Is there any implemenation that does not do
> that per default ?
>
>

Some sorting algorithms are stable (i.e. keep duplicate keys in order) and
some are not. Quicksort and heapsort for example are not stable.

Most external sorts, at least the ones that I have used, give you some
option to control this.

If the sort available to you does not allow you to control this you can
process the file with a program and add an integer field representing the
record's position in the file. Then use that field in your sort keys to keep
duplicates in order. You could do this with a stand alone COBOL program
folloed by an external sort, or you could use an input-procedure to add the
integer to the record that you are sorting.


William M. Klein

unread,
Apr 15, 2007, 12:23:19 PM4/15/07
to
Roger,
If you are asking this for an OpenCOBOL implantation purpose, I thought that
I would add two more "bits of information"

1) There is nothing in the current (or past) COBOL Standard that says that you
CAN"T default to "duplicates in order" when doing an internal SORT - even if the
DUPLICATES phrase isn't specified.

2) As far a compatibility with any implementation that does NOT *always* default
to "duplicates in order" (when DUPLICATES not specified), I think that it is
fair to say that "results are unpredictable" so NO user of OpenCOBOL would
demand that you implement any specific non-duplicates-in-order results.

--
Bill Klein
wmklein <at> ix.netcom.com

"Roger While" <si...@sim-basis.de> wrote in message
news:evok5f$gu$00$1...@news.t-online.com...

HeyBub

unread,
Apr 15, 2007, 2:46:58 PM4/15/07
to
Roger While wrote:
> Is there any implemenation that does not do
> that per default ?

We recently had a programmer do a silly thing. When the user clicked on a
column in a listview box to sort the column, the programmer sorted an
internal table in response. What he didn't know, was that the sort did not
sort the same way as the column when confronted with duplicates.

Had there been a lot of duplicates (such as "city") this would have been
obvious in testing. As it was, the project got released.

You can imagine...


Roger While

unread,
Apr 16, 2007, 4:16:04 AM4/16/07
to
Bill,
I only asked out of interest. OC does a stable sort ie. defaults
to "duplicates in order".

Roger

"William M. Klein" <wmk...@nospam.netcom.com> schrieb im Newsbeitrag
news:WjsUh.350982$Jt2....@fe04.news.easynews.com...

0 new messages