sort

sort(x)

sort(x, compare)

Try it yourself:

See also:

sort(): Ordering Collection Values

sort() orders values in a collection. Sorted data is useful for ranks, quantiles, binary search preparation, and readable reports.

Ordering choices

Decide whether ascending or descending order is required and how ties should be treated. Use compare() for general ordering logic and compareText() for textual values. Sorting may rearrange associated records, so preserve relationships deliberately.

Use quantileSeq() for percentile analysis, min() and max() for extrema without retaining a full sorted result.

Try Sort in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions