# Engineering a sort function

@article{Bentley1993EngineeringAS, title={Engineering a sort function}, author={Jon Louis Bentley and M. Douglas McIlroy}, journal={Software: Practice and Experience}, year={1993}, volume={23} }

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.

## 206 Citations

### Pattern-defeating Quicksort

- Computer ScienceArXiv
- 2021

A new solution for the Dutch national flag problem is proposed, requiring no three-way comparisons, which gives quicksort a proper worst-case runtime of O(nk) for inputs with k distinct elements.…

### A better approach to QuickSort implementation

- Computer Science
- 2012

This paper formulates an alternative implementation of Quicksort that is faster and simpler and based on some profound basic principles and a better partitioning algorithm.

### Experiments for Algorithm Engineering

- Computer ScienceCOCOON
- 2003

A highly tuned version of the Quicksort algorithm was implemented in the Unix system’s main memory sort function, qsort, for two decades, and performed admirably.

### A Performance Study of Some Sophisticated Partitioning Algorithms

- Computer Science
- 2011

A careful study of partitioning algorithms on modern machines with the help of state of the art performance analyzers, chooses the best partitioning algorithm on the basis of some crucial performance indicators.

### Engineering Java 7's Dual Pivot Quicksort Using MaLiJan

- Computer ScienceALENEX
- 2013

This paper uses the new tool MaLiJAn to confirm that asymmetric pivot choices are preferable to symmetric ones for this Quicksort variant asymptotically for combinatorial cost measures such as the total number of executed instructions.

### Review of algorithms and data structures: the basic toolbox by Kurt Mehlhorn and Peter Sanders

- Computer ScienceSIGA
- 2011

A toolbox: in the hands of an accomplished craftsman, it has a carefully selected set of the most commonlyused implements appropriate to the most frequently-encountered tasks. In the hands of a hack,…

### Introspective sorting and selection revisited

- Computer ScienceSoftw. Pract. Exp.
- 2000

Experimental results show that a simple rule for fine‐grained introspection that detects potential worst‐case performance after only a small constant number of partitioning steps and the use of remedial randomization as an intervention strategy in order to reduce the performance penalty for false positives provide significant improvements in the running time.

### Building a new sort function for a C library

- Computer ScienceSoftw. Pract. Exp.
- 2004

A library function based on Chen's Proportion Extend Sort (psort) which is robust and faster than BM qsort is introduced, inspired by the fact that psort is generally faster than qsort, and in the worst case, qsort requires O(n2) comparisons, while psort requiresO(n log n).

### Java 7's Dual-Pivot Quicksort

- Computer Science
- 2014

This thesis focuses on the precise and detailed average case analysis of Quicksort, aiming at the flavor of Knuth's series “The Art of Computer Programming”, and tries to understand the efficiency of the algorithms at different levels of abstraction.

## References

SHOWING 1-10 OF 26 REFERENCES

### Implementing Quicksort programs

- Computer ScienceCACM
- 1978

A detailed implementation combining the most effective improvements to Quicksort is given, along with a discussion of how to implement it in assembly language, including how to apply various code optimization techniques.

### The UNIX system: Theory and practice in the construction of a working sort routine

- Computer ScienceAT&T Bell Laboratories Technical Journal
- 1984

Because comparison in the standard UNIX™ operating system sort routine, /bin/sort, is interpretive, it is generally more time-consuming than the standard paradigm of comparing two integers. When a…

### Quicksort with Equal Keys

- Computer ScienceSIAM J. Comput.
- 1977

It is shown that, of the three strategies which have been suggested for dealing with equal keys, the method of always stopping the scanning pointers on keys equal to the partitioning element performs best.

### A retargetable compiler for ANSI C

- Computer ScienceSIGP
- 1991

lcc is a new retargetable compiler for ANSI C. Versions for the VAX, Motorola 68020, SPARC, and MIPS are in production use at Princeton University and at AT&T Bell Laboratories. With a few…

### The errors of tex

- Computer ScienceSoftw. Pract. Exp.
- 1989

The history of the TEX project can teach valuable lessons about the preparation of highly portable software and the maintenance of programs that aspire to high standards of reliability.

### Algorithms in C

- Computer Science
- 1990

Algorithms in C is a comprehensive repository of algorithms, complete with code, with extensive treatment of searching and advanced data structures, sorting, string processing, computational geometry, graph problems, and mathematical algorithms.

### Optimistic sorting and information theoretic complexity

- Computer ScienceSODA '93
- 1993

Simple modifications to insertion sort and merge sort improve their performance on incompletely shuffled data, and the modified merge sort proves efficient both in theory and in practice.

### Programming pearls

- Computer ScienceCACM
- 1987

This book is about programming pearls whose origins lie beyond solid engineering, in the realm of insight and creativity, and a new theme in this edition is how to evaluate and use software components.

### Structured Programming with go to Statements

- Computer ScienceCSUR
- 1974

For serious students of structured programming, and also for language designers, Knuth's "Structured Programming with go to Statements" is probably the paper to read. It is by far the most complete…