Sorting an array in better way

_ROOT Version:6.13/01
Platform: Not Provided
Compiler: Not Provided

Dear Rooters,

I am using TClonesArray. Before filling the 2D histogram I am supposed to sort the contents (global bins and point coordinates) of the array for each event. So, simply I used function Sort() but when I increase the number of events O(1000) its performance is too slow.
First, I thought it is related to memory leaks, but it isn’t.
Now I want to know if there is a better or more elegant way to do this?
Actually, I found TMath::Sort but I am confused to use this function.
Any help would be gladly appreciated.



Have you tried to use an ordered container, as a “map” or a “set”? (the elements are emplaced by order, so you dont have to sort them after inserting new elements)

Best regards,


Sorry for delay. No, I am not familiar with that. But, it also seems great to use.
Finally I found and solved my problem coming from a technical error in filling array.
Anyway, Thanks for your valuable time to reply. :slight_smile:


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.