Looking for a c++ function for sorting an array of floats and returning the sorted results + index

Looking for some C++ help here. I’m working on a racing game. I record the cars position by getting their distance along a spline track - which is represented as a float. A race would be made up of about 15-20 cars. The cars positions are stored in an array of floats. So, naturally I need to sort the array of floats so that I can put them on the score board in their proper places. I have a blueprint sort routine that works somewhat - but I think there is some kind of memory leak or some issue with the routine that I have not figured out. I’m also thinking that because distance values start to increase by quite a bit as you continue as you increase lap counts NOTE: Calculation: a racers position = (total spline distance + the racers current position along the spline ) * the number of laps the player has done. so the racers position pretty quickly get into the tans / hundreds of millions.

So I need a sort routine that inputs a single array of floats and the outputs two arrays: (1) the sorted floats (from largest to smallest) and (2) the index of the order of the sorted array. Basically, if I had 3 cars racing and their distances were [1] 200, [2] 100, [3] 300 and I sorted them I would end up with array 1 = [300,200,100] and the second array with [3, 1, 2]. I’m not a c++ programmer (just blueprint). I’ve used some AI engines to generate some code that should work, but I have not been able ot figure out how to compile it into a solution. So hoping that someone can craft a quick sort routine function library that I could load into my project.

below is the blueprint sort routine that I’m using currently.