Hi,

I’m trying to sort a tree according to a number stored in the tree. This has been discussed here before and I have adopted the script to my needs. However, something is seriously wrong, since my sorted tree is not quite sorted after the operation. Once every few hundred entries there is one entry that is out of order as illustrated in the output of TTree::Scan

```
* 2996 * 32950 *
* 2997 * 32950 *
* 2998 * 38461 *
* 2999 * 32950 *
* 3000 * 32950 *
```

I really have no idea what I could be doing wrong to cause a behavior like this and I would appreciate any help.

If you want to reproduce the problem and look at the code I use, please save the attached code files and a sample tree to a directory and just execute the following command in root:

```
root [0] .L TreeClass2.C+
root [1] .L treesort2.C+
root [2] treesort2()
Reading Run numbers
------ PROCESSING ev NO. 499000 of 500000 ------
Sorting Run numbers
processing branch: runNumber
processing branch: gamma_ndigis
processing branch: gamma_digiList_phi
processing branch: gamma_digiList_theta
******************************************************************************
*Tree :ntp1 : Isr Gammas *
*Entries : 500000 : Total = 109669905 bytes File Size = 24727439 *
* : : Tree compression factor = 4.44 *
******************************************************************************
*Br 0 :runNumber : runNumber/I *
*Entries : 500000 : Total Size= 2025670 bytes File Size = 51838 *
*Baskets : 252 : Basket Size= 8000 bytes Compression= 38.87 *
*............................................................................*
*Br 1 :gamma_ndigis : gamma_ndigis/I *
*Entries : 500000 : Total Size= 2026444 bytes File Size = 565662 *
*Baskets : 252 : Basket Size= 8000 bytes Compression= 3.56 *
*............................................................................*
*Br 2 :gamma_digiList_phi : gamma_digiList_phi[gamma_ndigis]/I *
*Entries : 500000 : Total Size= 52819033 bytes File Size = 13292716 *
*Baskets : 6849 : Basket Size= 8000 bytes Compression= 3.96 *
*............................................................................*
*Br 3 :gamma_digiList_theta : gamma_digiList_theta[gamma_ndigis]/I *
*Entries : 500000 : Total Size= 52832743 bytes File Size = 10712073 *
*Baskets : 6849 : Basket Size= 8000 bytes Compression= 4.91 *
*............................................................................*
root [3]
```

Please let me know if more info is needed to track down this issue.

Thanks in advance for your help.

Cheers,

Andreas

treesort2.C (2.27 KB)

TreeClass2.h (3.98 KB)

TreeClass2.C (1.43 KB)