Sort fix
All checks were successful
Build Dusk / run-tests (push) Successful in 3m44s
Build Dusk / build-linux (push) Successful in 4m34s
Build Dusk / build-psp (push) Successful in 2m43s

This commit is contained in:
2026-01-28 11:44:25 -06:00
parent 69d64eb8e4
commit ae8a869f64
2 changed files with 16 additions and 7 deletions

View File

@@ -60,12 +60,12 @@ void sortQuick(
qsort(array, count, size, compare); qsort(array, count, size, compare);
} }
void sortArrayU8(uint8_t *array, const size_t count) { int sortArrayU8Compare(const void *a, const void *b) {
int_t compare(const void *a, const void *b) { uint8_t valA = *(const uint8_t*)a;
uint8_t valA = *(const uint8_t*)a; uint8_t valB = *(const uint8_t*)b;
uint8_t valB = *(const uint8_t*)b; return (valA > valB) - (valA < valB);
return (valA > valB) - (valA < valB); }
}
return sort((void*)array, count, sizeof(uint8_t), compare); void sortArrayU8(uint8_t *array, const size_t count) {
return sort((void*)array, count, sizeof(uint8_t), sortArrayU8Compare);
} }

View File

@@ -47,6 +47,15 @@ void sortQuick(
*/ */
#define sort sortQuick #define sort sortQuick
/**
* Comparison function for uint8_t arrays.
*
* @param a First element.
* @param b Second element.
* @return Negative if a < b, zero if a == b, positive if a > b.
*/
int sortArrayU8Compare(const void *a, const void *b);
/** /**
* Sorts an array of uint8_t in ascending order. * Sorts an array of uint8_t in ascending order.
* *