}
bool ascending_and_even(int a, int b) {
- return (ascending(a, b) && (a % 2 == 0));
+ return (((a % 2 != 0) && (b % 2 == 0)) || ((a % 2 == 0) && (b % 2 == 0) && ascending(a, b)) \
+ || ((a % 2 != 0) && (b % 2 != 0) && ascending(a, b)));
}
bool ascending_and_odd(int a, int b) {
- return (ascending(a, b) && (a % 2 != 0));
+ return (((a % 2 == 0) && (b % 2 != 0)) || ((a % 2 == 0) && (b % 2 == 0) && ascending(a, b)) \
+ || ((a % 2 != 0) && (b % 2 != 0) && ascending(a, b)));
}
-static bool sort_first(int* array, unsigned length, criteria_cb criteria) {
+static bool sort_first(int* array, unsigned length, s_criteria_cb sort_criteria) {
bool rt = false;
for (unsigned i = 0; i < length-1; i++) {
- if (criteria(array[i], array[i+1])) {
+ if (sort_criteria(array[i], array[i+1])) {
swap_int(&array[i], &array[i+1]);
- if (!rt) { rt = true; };
+ rt = true;
}
}
return rt;
}
-/* this function is awaited in the array.c file */
-void sort_bubble_array(int* array, unsigned length, criteria_cb criteria) {
+/* the feature of this function is awaited in the array.c file */
+void sort_bubble_array(int* array, unsigned length, s_criteria_cb sort_criteria) {
bool rt;
do {
- rt = sort_first(array, length, criteria);
+ rt = sort_first(array, length, sort_criteria);
} while (rt);
}