Page 1 of 1

difference between internal sort and external sort

PostPosted: Sat Aug 21, 2010 9:57 pm
by nithyanandhan
can anyone explain me what is the difference between the internal sort and external sort? under wat category the dfsort comes under? i head that in jcl while doing sorting if we didnt specify the workfile the jcl will automatically use the sysout statement as the workfile. how far it is? i need a clear view of internal and external sort with respect to their names? thanks in advance.

Re: difference between internal sort and external sort

PostPosted: Sat Aug 21, 2010 11:28 pm
by dick scherrer
Hello,

The "name" of the sort excutable has nothing to do with internal versus external sorting.

Internal sorting is done when the sort is invoked from within an application program (say a COBOL program using the SORT statement).

External sorting is done when the sort is invoked directly in the JCL.

i head that in jcl while doing sorting if we didnt specify the workfile the jcl will automatically use the sysout statement as the workfile. how far it is?

You need to read the documentation for the sort product that is being used on your system to learn about "workfiles" and "sysout". You also need to change where you "hear" things - this source is completely off the mark.

How far is what?

Re: difference between internal sort and external sort

PostPosted: Sun Aug 22, 2010 12:26 am
by steve-myers
Mr. scherrer's discussion is good but not quite my definition. As far as I'm concerned, an internal sort is when you use a function like the C library's qsort function. With qsort all of the data is in memory, and no external storage is required. I personally consider the sort function as in the Cobol SORT verb or the PL/I PLISRTx functions that use an external sort product, such as DFSORT or Syncsort as external sorts, though Mr. scherrer regards them as internal sorts.

Back in the early 90s I wrote an Assembler qsort, based on the qsort example in the excellent K & R "The C Programming Language," that used an interface modeled very closely on the C language standard library qsort function. My qsort has served me well for nearly 20 years for internal sorts. In 20 years I did an external sort using the Assembler interface to the external sort just twice, and once was to compare my qsort with external products. My conclusion was I was better than the external products for a few hundred, or even a few thousand items because of the external products start up costs, but once that was overcome they beat my code handily.

Re: difference between internal sort and external sort

PostPosted: Sun Aug 22, 2010 12:49 am
by dick scherrer
Hi Steve,

Probably a good thing to keep in mind is that less than 1% of the people working on business applications on an IBM mainframe are familiar with "qsort". A similar (but a bit larger) group is familiar with a "finger sort" or a "bubble sort" as many were required to write such as part of their training. . . And that may no longer be part of the training.

As you've written 2 assembler executions/invocations of the system sort product you've done 2 more than i have<g>. All of the assembler i've worked with (other than helping students with homework) have been "internals" or other "system" type code and not processors of lots of external data.

Once COBOL took over for business applications, very few places still used assembler to process large amounts of business data - the organizations are unwilling/unable to support a large amount of assembler work.

Oh, btw, "Mr Scherrer" was my Dad's dad . . . ;)

Have a great weekend,

d

Re: difference between internal sort and external sort

PostPosted: Sun Aug 22, 2010 6:16 am
by steve-myers
Well, the comment about sort training is all too true. I've done "bubble" sorts in Assembler. They look very elegant; lots of BXH and BXLE instructions, and very few instructions over all. Efficent it's not, but it sure does look pretty. Of couse, most of the readers here will be scratching their heads. BXH? BXLE? What the ???? are they. Even people that have had alleged Assembler training are probably asking that question, which may reflect on the quality of Assembler training and usage. Efficient sorting is actually quite hard; that's why we pay the big bucks for DFSORT or Syncsort.

Re: difference between internal sort and external sort

PostPosted: Mon Aug 23, 2010 11:20 pm
by Frank Yaeger
can anyone explain me what is the difference between the internal sort and external sort? under wat category the dfsort comes under?


From what I've seen, the common definition is that an external sort uses the sort product directly (e.g. PGM=SORT) whereas an internal sort calls the sort product from a program (e.g. COBOL calls DFSORT). But as you can see from the previous posts, that definition is not universally accepted.

DFSORT is a sort utility. It can be called directly or from a program.

This reference might be of help in regard to direct calls to DFSORT vs program calls to DFSORT:

http://publibz.boulder.ibm.com/cgi-bin/ ... 0528173317

i head that in jcl while doing sorting if we didnt specify the workfile the jcl will automatically use the sysout statement as the workfile. how far it is?


No, that's not true. If you don't specify workfiles, DFSORT will use dynamically allocated work files. The SYSOUT DD contains DFSORT messages.

i need a clear view of internal and external sort with respect to their names?


DFSORT can be called directly using PGM=SORT or PGM=ICEMAN. DFSORT can be called from a program using LINK, ATTACH or XCTL with EP=SORT or EP=ICEMAN.

Re: difference between internal sort and external sort

PostPosted: Fri Sep 03, 2010 10:27 am
by Michael B
Internal sort is when an application program calls sort. External sort (AKA 'stand alone sort') is when you call the sort program directly, via JCL. Either may have (but is not required to have) an input routine (to only select certain records, or certain fields of selected records, etc.) and and output routine (to do something with the records after they are sorted, such as print a report). In a COBOL program the input routine is the reserved word 'INPUT PROCEDURE' followed by a SECTION name that performs the procedure. The output routine is the reserved word 'OUTPUT PROCEDURE' followed by a SECTION which prints the report (or what ever it is you want to do). If you don't need an input procedure (i.e. you want every field of every record) use the reserved word USING file-name and likewise if you don't want the output procedure code GIVING file-name. Stand alone sorts may also have input procedures and output procedures if desired. The input procedure is called sort exit 'E15' and is a program you write which will select the records you want (and reformat the fields, if you tell it to) the output procedure is 'E35', which you will write to do whatever you need to after the records are sorted.

A million years ago my mentor told me "One day you'll get a job and your boss will tell you to sort something. Ask him if he wants an internal sort or an external sort. If he says 'internal' but doesn't give a reason, that means he doesn't know how to do external. If he says 'external' but doesn't give a reason, that means he doesn't know how to do internal. If he says one or the other and gives a reason (such as easier to code, will run faster etc.) then he understands both. If he says 'you're the programmer, do it however seems better to you' then you can bet your paycheck that he doesn't understand either of them.

Re: difference between internal sort and external sort

PostPosted: Mon Sep 13, 2010 11:20 pm
by nithyanandhan
thank you for all who posted reply for this .i am very glad to see this replies. and i am clear about the sort now.
thanku again. :)