# 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.

## 208 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,…

### 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).

### Towards Automation Of Sorting Implementations For SIMD Architectures

- Computer Science
- 2011

The experiments performed on Intel Core-2 duo and Power-4 processors using icc and gcc compilers show that the approach improves the performance of the sorting code on these architectures.

### Accessing hardware performance counters in order to measure the influence of cache on the performance of integer sorting

- Computer ScienceProceedings International Parallel and Distributed Processing Symposium
- 2003

It is demonstrated through experiments on an Athlon processor that a good balance between L1 data cache misses and retired instructions provides the fastest algorithm for sorting in practical cases and a new flavour of merge-sort is developed and it beats its rival.

## References

SHOWING 1-10 OF 24 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.

### 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…

### Algorithm 347: an efficient algorithm for sorting with minimal storage [M1]

- MathematicsCACM
- 1969

The real procedure gauss computes the area under the left-hand portion of the normal curve by using National Bureau of Standards formulas 26.6.4, 26.5, and 26.8 for computation of the statistic and the approximation for the approximation.