>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?
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...
Micro Focus COBOL 3.2.24 when sorting a table;
but apparently not when sorting a file.
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.
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
--
Bill Klein
wmklein <at> ix.netcom.com
"Alistair" <alis...@ld50macca.demon.co.uk> wrote in message
news:1176582767.7...@p77g2000hsh.googlegroups.com...
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
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).
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...
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.
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...
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
"William M. Klein" <wmk...@nospam.netcom.com> schrieb im Newsbeitrag
news:WjsUh.350982$Jt2....@fe04.news.easynews.com...