Function sortUnstable [src]

Sorts a slice in-place using an unstable algorithm (does not preserve relative order of equal elements). Time complexity: O(n) best case, O(n log n) worst case and average case. Generally faster than stable sort but order of equal elements is undefined. Uses pattern-defeating quicksort (PDQ) algorithm which performs well on many data patterns. For stable sorting that preserves equal element order, use sort.

Prototype

pub fn sortUnstable( comptime T: type, items: []T, context: anytype, comptime lessThanFn: fn (@TypeOf(context), lhs: T, rhs: T) bool, ) void

Parameters

T: typeitems: []TlessThanFn: fn (@TypeOf(context), lhs: T, rhs: T) bool

Source

pub fn sortUnstable( comptime T: type, items: []T, context: anytype, comptime lessThanFn: fn (@TypeOf(context), lhs: T, rhs: T) bool, ) void { std.sort.pdq(T, items, context, lessThanFn); }