diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-04-02 13:08:06 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-04-02 13:08:06 -0400 |
| commit | c73e96ff916209d74e2be9bd7d8de3758685ce4d (patch) | |
| tree | 8f902fea5b6790061e48600243f0f8faeded32dd /builtins/table.c | |
| parent | b6534ce34706d1a98584e5f916107d91da072346 (diff) | |
Add comparison operator <> and array method to sort by a custom
comparison function
Diffstat (limited to 'builtins/table.c')
| -rw-r--r-- | builtins/table.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtins/table.c b/builtins/table.c index 32bf6858..956c0565 100644 --- a/builtins/table.c +++ b/builtins/table.c @@ -441,8 +441,8 @@ public int32_t Table$compare(const table_t *x, const table_t *y, const TypeInfo return (x->entries.length > y->entries.length) - (x->entries.length < y->entries.length); array_t x_entries = x->entries, y_entries = y->entries; - Array$sort(&x_entries, table.key); - Array$sort(&y_entries, table.key); + Array$sort(&x_entries, (closure_t){.fn=generic_compare, .userdata=(void*)table.key}, table.key); + Array$sort(&y_entries, (closure_t){.fn=generic_compare, .userdata=(void*)table.key}, table.key); for (int64_t i = 0; i < x_entries.length; i++) { void *x_key = x_entries.data + x_entries.stride * i; void *y_key = y_entries.data + y_entries.stride * i; |
