Sort fix
This commit is contained in:
@@ -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);
|
}
|
||||||
}
|
|
||||||
|
void sortArrayU8(uint8_t *array, const size_t count) {
|
||||||
return sort((void*)array, count, sizeof(uint8_t), compare);
|
return sort((void*)array, count, sizeof(uint8_t), sortArrayU8Compare);
|
||||||
}
|
}
|
||||||
@@ -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.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user