diff options
Diffstat (limited to 'sorters.c')
-rw-r--r-- | sorters.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1,3 +1,6 @@ +#include <stddef.h> +#include <stdlib.h> + #include "sorters.h" const struct sorter sorters[] = { @@ -8,3 +11,13 @@ const struct sorter sorters[] = { { .name = "wikisort", .func = wikisort }, { 0 } }; + +void assert_sorted(int *buffer, size_t size) +{ + if (!size) return; + int prev = buffer[0]; + for (size_t i = 1; i < size; i++) { + if (prev > buffer[i]) abort(); + prev = buffer[i]; + } +} |