Hi there again,
my problem should have an easy answer but i can’t seem to figure it out.
I have an unsorted Array of floats.

Array<float> dateCreatedArray;

i sort the array with

dateCreatedArray.sort(sorter);

the sorting works and i get a new sorted array,
now i need to know what the new index is of the smallest number in my old array so i can use that index number in another function. (to make sure i load in the last created file).
currently i’m using this method but this doesn’t work.

int indexOfLastCreatedFile = dateCreatedArray.indexOfSorted(sorter, dateCreatedArray.getFirst());

i’ve tried

int indexOfLastCreatedFile = dateCreatedArray.indexOfSorted(sorter, dateCreatedArray.getLast());

as well but that doesn’t work either.
how do i get the right index?

You can put the values in a std::map <float, int> that maps the float values to their original indices.

std::map is inherently ordered by its key, therefore its first (key, mapped) pair (obtained with begin() ) will have the lowest float value as its key, and the original index as the mapped int.

Code example:

#include <map>
int main ()
{
std::map <float, int> value_to_original_index;
value_to_original_index [0.3f] = 3;
value_to_original_index [2.6f] = 5;
value_to_original_index [0.1f] = 7;
const auto lowest = value_to_original_index.begin ();
const float value = lowest->first;
const int original_index = lowest->second;
printf ("%f at %d\n", value, original_index);
return 0;
}