Wolfram Language

Implement Quicksort

The Wolfram Compiler allows efficient implementation of a variety of standard algorithms, for example, quicksort. Many of these algorithms operate on compound types, such as arrays, that can be indicated using TypeSpecifier.

The following is a straightforward implementation of quicksort, focusing on minimum code rather than maximum speed. TypeSpecifier is used to indicate that the input is a depth-1 array of machine integers, and FunctionCompile automatically determines that the return value is also an array of the same type.

Generate data to be sorted.

Sort the data.

Related Examples

de es fr ja ko pt-br zh