Using Radix sort(Descend) to get sorted Indices of a long array consists of 8-bit integers(uchar).
e.g.
uchar data[10] = {2,8,6,25,255,23,96,102,235,0}; // actual one has million values
size_t n = 10;
int index[n]; std::iota(std::begin(index), std::end(index), 0); // Initialise indices
radixSort(std::begin(index), n, &data[0]); // TARGET FUNCTION
return index; // OUTPUT - Sorted index
Output:
{4, 8, 7, 6, 3, 5, 1, 2, 0, 9}
I tried below links but didn't succeed.