--- layout: site.njk title: zul.sort ---

Helpers for sorting strings and integers

{% highlight zig %} // sorting strings based on their bytes var values = [_][]const u8{"ABC", "abc", "Dog", "Cat", "horse", "chicken"}; zul.sort.strings(&values, .asc); // sort ASCII strings, ignoring case zul.sort.asciiIgnoreCase(&values, .desc); // sort integers or floats var numbers = [_]i32{10, -20, 33, 0, 2, 6}; zul.sort.numbers(i32, &numbers, .asc); {% endhighlight %}

sort.strings(values: [][]const u8, direction: Direction) void

Sorts the values in-place using byte-comparison. The sort is unstable (i.e. there is no guarantee about how duplicate values are ordered with respect to each other). Direction can be .asc or .desc

sort.asciiIgnoreCase(values: [][]const u8, direction: Direction) void

Sorts the values in-place, ignoring ASCII casing. The sort is unstable (i.e. there is no guarantee about how duplicate values are ordered with respect to each other). Direction can be .asc or .desc

sort.number(comptime T: type, values: []T, direction: Direction) void

Sorts the values in-place. The sort is unstable (i.e. there is no guarantee about how duplicate values are ordered with respect to each other). Direction can be .asc or .desc. T must be an integer or float type (i.e. i32, f64).