Hi ROOTers,
this gotta be really easy: How can I sort a TArray? Like, having a [color=green]void TArrayD::Sort(Bool_t direction)[/color]? Or at least [color=green]TMath::Sort[/color] taking TArrays? How can I do this myself without having to copy the TArray into a double*?
Thanks!
Cheers,
Rafi
If you have TArrayd array, do
int n = array.fN;
int *index = new int[n];
TMath::Sort(n,array.fArray,index)
Rene
Hi Rene,
true, that’s easy enough
Thanks!
Cheers,
Rafi
[quote=“rlang”]Hi ROOTers,
this gotta be really easy: How can I sort a TArray? Like, having a [color=green]void TArrayD::Sort(Bool_t direction)[/color]? Or at least [color=green]TMath::Sort[/color] taking TArrays? How can I do this myself without having to copy the TArray into a double*?
Thanks!
Cheers,
Rafi [/quote]
I think TArrayD is a kind of a wrapper around of
Rene can correct me if I am wrong on this.
You therefore can use STD algorithms with it, like the following: