TTree::GetTreeIndex sorted?

Hi all,

I was wondering if I can assume that TTree::GetTreeIndex gives me a sorted list of indices. I was hoping to use this code to get all entries with a given index, but this can only be used if the indices are sorted:

CompositeParticleBag NtupleReader::getCompositeParticles(Int_t run,  Int_t event, std::string key, TTree* CP){
  CompositeParticleBag theCPs;
  
  TTreeIndex *indexes= (TTreeIndex*)CP->GetTreeIndex();
  if (indexes && indexes->GetN()) {
    Long64_t value = Long64_t(run)<<31;
    value += event;
    Int_t i = TMath::BinarySearch(indexes->GetN(), indexes->GetIndexValues(), value);
    if (i >= 0) {
      while( indexes->GetIndexValues()[i] == value ) {
        theCPs.push_back(readCompositeParticleTree(indexes->GetIndex()[i],key,CP));
        i++;
      }
    }
  }
  return theCPs;
}

Thanks,
N.

The TTree::BuildIndex sorts the pair (majorname,minorname) by increasing values.
This function assumes that the pair is unique in the data set (typycally run,event_number).
see doc of TTreeIndex at root.cern.ch/root/html/TTreeIndex.html

Rene