Hello,
my purpose is to sort a matrix array using this library
ArduinoSort library by Emil Vikström 17 Feb 2017
The IDE is 1.8.7 and Arduino core is 1.6.23
This is my test matrix array but I will use a struct were the first field will be a char[] (all elements with same length) and the second field will be an unsigned int
uint16_t my2dArray[5][2] = {
{45689, 2},
{35497, 4},
{12365, 8},
{25698, 7},
{45689, 1}
};
Following the instructions the function should be used in this way
sortArray(my2dArray, 5, firstIsLarger2);
The library uses templates, this is the template that will be used, taken from the error message
// Sort an array with custom comparison function
template<typename AnyType> void sortArray(AnyType array[], size_t sizeOfArray, bool (*largerThan)(AnyType, AnyType));
Now the problem arise because I am a noob in C/C++ and I don't know how to declare my comparison function
These are my attempts followed by the error that I get.
bool firstIsLarger2(unsigned int first[], unsigned int second[])
deduced conflicting types for parameter 'AnyType' ('unsigned int [2]' and 'unsigned int*')
bool firstIsLarger2(unsigned int first, unsigned int second)
deduced conflicting types for parameter 'AnyType' ('unsigned int [2]' and 'unsigned int')
bool firstIsLarger2(unsigned int first[2], unsigned int second[2]) {
deduced conflicting types for parameter 'AnyType' ('unsigned int [2]' and 'unsigned int*')
Full code is attached
ArduinoSortTest.zip (2.37 KB)