Sorting Strings in Zig

from blog openmymind.net, | ↗ original
First, the code: std.mem.sort([]const u8, values, {}, stringLessThan); fn stringLessThan(_: void, lhs: []const u8, rhs: []const u8) bool { return std.mem.order(u8, lhs, rhs) == .lt; } std.mem.sort takes 4 arguments: the type of value we're sorting, the list of values to sort, an arbitrary context, and a function. The last argument, the...