summaryrefslogtreecommitdiff
path: root/sorters.c
diff options
context:
space:
mode:
Diffstat (limited to 'sorters.c')
-rw-r--r--sorters.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sorters.c b/sorters.c
index 99e000e..8db94e0 100644
--- a/sorters.c
+++ b/sorters.c
@@ -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];
+ }
+}