| ... | ... | @@ -220,6 +220,18 @@ pub fn sortBySlice(comptime T: type, items: []T, comptime field: std.meta.FieldE |
| 220 | 220 | }.f); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | pub fn lessThanSlice(comptime T: type) fn (void, T, T) bool { |
| 224 | return struct { |
| 225 | fn f(_: void, lhs: T, rhs: T) bool { |
| 226 | const result = for (0..@min(lhs.len, rhs.len)) |i| { |
| 227 | if (lhs[i] < rhs[i]) break true; |
| 228 | if (lhs[i] > rhs[i]) break false; |
| 229 | } else false; |
| 230 | return result; |
| 231 | } |
| 232 | }.f; |
| 233 | } |
| 234 | |
| 223 | 235 | pub fn containsString(haystack: []const string, needle: string) bool { |
| 224 | 236 | for (haystack) |item| { |
| 225 | 237 | if (std.mem.eql(u8, item, needle)) { |