Engineering a sort function

We recount the history of a new qsortfunction for a C library. Our function is clearer, faster and more robust than existing sorts. It chooses partitioning elements by a new sampling scheme; it partitions by a novel solution to Dijkstra's Dutch National Flag problem; and it swaps efficiently. Its behavior was assessed with timing and debugging testbeds, and with a program to certify performance. The design techniques apply in domains beyond sorting.

[1]  Donald E. Knuth,et al.  Structured Programming with go to Statements , 1974, CSUR.

[2]  Christopher W. Fraser,et al.  A retargetable compiler for ANSI C , 1991, SIGP.

[3]  Niklaus Wirth,et al.  Algorithms + Data Structures = Programs , 1976 .

[4]  Peter M. McIlroy Optimistic sorting and information theoretic complexity , 1993, SODA '93.

[5]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[6]  C. Q. Lee,et al.  The Computer Journal , 1958, Nature.

[7]  Richard C. Singleton Algorithm 347: an efficient algorithm for sorting with minimal storage [M1] , 1969, CACM.

[8]  Jon Louis Bentley,et al.  Programming pearls , 1987, CACM.

[9]  Robert Sedgewick,et al.  Implementing Quicksort programs , 1978, CACM.

[10]  J. P. Linderman The UNIX system: Theory and practice in the construction of a working sort routine , 1984, AT&T Bell Laboratories Technical Journal.

[11]  Robert Sedgewick,et al.  Algorithms in C , 1990 .

[12]  Robert Sedgewick Quicksort with Equal Keys , 1977, SIAM J. Comput..

[13]  Roger S. Scowen Algorithm 271: quickersort , 1965, CACM.

[14]  Donald E. Knuth,et al.  The errors of tex , 1989, Softw. Pract. Exp..

[15]  Alistair Moffat,et al.  A Framework for Adaptive Sorting , 1992, SWAT.

[16]  M. V. Wilkes,et al.  The Art of Computer Programming, Volume 3, Sorting and Searching , 1974 .

[17]  Edsger W. Dijkstra,et al.  A Discipline of Programming , 1976 .

[18]  James N. Lyness,et al.  Comments on the Nature of Automatic Quadrature Routines , 1976, TOMS.