vendredi 1 novembre 2019

specifying arguments to the compare function in C++ sort

My question is how the compare function in the C++ sort function takes parameters. if I want to sort an array but also want to preserve the index of the elements i thought of sorting the index array based on the elements in the actual array. The issue is i am not able to find how to pass the parameters to the compare function. suppose the array is 3 5 4 2 indexes are 0 1 2 3 . I want the index array output 3 0 2 1 which is 2 3 4 5 . how can i do that using the sort function.

Aucun commentaire:

Enregistrer un commentaire