4 bool ascending(int a
, int b
) {
8 bool descending(int a
, int b
) {
12 bool ascending_and_even(int a
, int b
) {
13 return (ascending(a
, b
) && (a
% 2 == 0));
16 bool ascending_and_odd(int a
, int b
) {
17 return (ascending(a
, b
) && (a
% 2 != 0));
20 static bool sort_first(int* array
, unsigned length
, criteria_cb criteria
) {
22 for (unsigned i
= 0; i
< length
-1; i
++) {
23 if (criteria(array
[i
], array
[i
+1])) {
24 swap_int(&array
[i
], &array
[i
+1]);
25 if (!rt
) { rt
= true; };
31 /* this function is awaited in the array.c file */
32 void sort_bubble_array(int* array
, unsigned length
, criteria_cb criteria
) {
35 rt
= sort_first(array
, length
, criteria
);