How to write a sorting program that will sort everything?

Tim McDaniel mcdaniel at adi.com
Tue Mar 26 02:54:14 AEST 1991


In article <1991Mar23.164807.7318 at helios.physics.utoronto.ca>
neufeld at aurora.physics.utoronto.ca (Christopher Neufeld) writes:
   Huh? I may be relatively new to C but isn't the stdlib function
   qsort() an example of a program which does just that?

qsort() is a function, not a program, under the usual definition of
"program".  I believe that calling a function a program is a
deplorable confusion of terms.

As indicated before, a C *program* can be coded to sort many common
types.  Specifying the uncommon types is the problem.  Where
available, dynamic linking could be used, as could dynamic loading and
calling of code.  Extra command-line arguments to the program could
specify a sort predicate program, which could be called via system()
with hideous overhead on most systems.

This problem might be more suited for awk, perl, icon, or other
interpreted languages.  The user could then enter the comparison code
directly.

--
   "Of course he has a knife.  We all have knives.  It's 1183, and we're
   all barbarians."
Tim McDaniel                 Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Internet: mcdaniel at adi.com                UUCP: {uunet,sharkey}!amara!mcdaniel



More information about the Comp.lang.c mailing list