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.