Sorting of the objects into a TFile

Hello,
I created a TFile which contain several TH1. Let us say I have in my TFile the following histos : h1_a, h1_b, h2_a, h3_a
In a TBrowser, they appear following this order.
Now, I want to add more TH1 in my TFile, so I open my previous TFile in “UPDATE” mode and I add for exemple a new TH1 called h2_b with the Write() method.
At the end, I got the following order : h1_a, h1_b, h2_a, h3_a, h2_b
Is there any way to “place” h2_b between “h2_a” and “h3_a”. It is only for am easier reading in the TBrowser…

[quote=“pamputt”]Hello,
I created a TFile which contain several TH1. Let us say I have in my TFile the following histos : h1_a, h1_b, h2_a, h3_a
In a TBrowser, they appear following this order.
Now, I want to add more TH1 in my TFile, so I open my previous TFile in “UPDATE” mode and I add for exemple a new TH1 called h2_b with the Write() method.
At the end, I got the following order : h1_a, h1_b, h2_a, h3_a, h2_b
Is there any way to “place” h2_b between “h2_a” and “h3_a”. It is only for am easier reading in the TBrowser…[/quote]

Can you, please, clarify what you mean by “soring of the objects into a TFile”? When you writing object into file, nobody sorts anything using object’s name. Also, I do not think anybody intentionally sorts list of keys from file, so your request is quite weird. If you’re writing them in this order: h1_a, h1_b; (UPDATE) h2_a, h2_b; (UPDATE) h3_a, h3_b you see them in this order (whatever you mean by order).

Let us take the same example
First, I create a TFile and I write() h1_a and h2_b inside
In the Tbrowser, I have the following order

  • h1_a
  • h2_a
    Then, I reopen the Tfile with the “UPDATE” option and I write h1_b
    I close the TFile and in the TBrowser, I get the following order
  • h1_a
  • h2_a
  • h1_b
    I would like that the h1_b is between h1_a and h2_a (and not at the end of the list)

[quote=“pamputt”]Let us take the same example
First, I create a TFile and I write() h1_a and h2_b inside
In the Tbrowser, I have the following order

  • h1_a
  • h2_a
    Then, I reopen the Tfile with the “UPDATE” option and I write h1_b
    I close the TFile and in the TBrowser, I get the following order
  • h1_a
  • h2_a
  • h1_b
    I would like that the h1_b is between h1_a and h2_a (and not at the end of the list)[/quote]

Actually, I was wrong: items in a list view (on the right) are sorted, so if I write object with name ‘b’ first and later ‘a’, they are shown as ‘a’, ‘b’ in a browser. If sorted by names, items in a view are ordered using lexicographical comparison, and it can be a bit surprising that items’ names are not simply ‘a’ and ‘b’, they also include ‘;1’ part - so, if I have, for example, items with names from ‘a1’ to ‘a10’, after sorting I’ll have ‘a10;1’, ‘a1;1’, ‘a2;1’ … etc. - which is the right order (‘a10;1’ < ‘a1;1’, since int(‘0’) < int(’;’)).

So, when items sorted by name:
a) an item’s name includes also ‘;X’ part (where X is a digit) .
b) names are compared/ordered lexicographically.

Now back to your example - it’s not really possible, since: ‘h2_a;1’ is lexicographically > ‘h1_b;1’.
And if I follow you description, I’ll have: “h1_a;1”, “h1_b;1”, “h2_a;1” as expected.