I’m pretty new to zig, so to learn the language better I’ve recently been implementing a variety of sorting algorithms in zig, and I now want to convert them to a similar style to the standard library sorting algorithms. The only problem is that I’m not really sure how the “context” parameter works in said sorting algorithms.
From reading the standard library code it seems to only really be used when calling @TypeOf(context) (such as in the type for “lessThanFn”), but I’m not sure what the type of it is supposed to be since whenever I’ve seen the sorting functions be called its just been inputted as “{}” . For example
std.mem.sort(u8, &array, {}, comptime std.sort.asc(u8));
In the actual input parameters it’s type seems to just be anytype.
Could someone explain how “context” works, and what it’s purpose is?