Actually in my script I fill a python dictionary and then I loop over dictionary keys, and entries in dictionaries are not sorted. So it’s difficult to adding entries in a specified order.
Following your other answer I managed building a different TLegend with just the entry I want to be showed as first.
starting with python2.4, there is the “sorted” builtin function that takes an iterable sequence and turns it into a sorted list. For your dictionary example, that would be “sorted(myDict)” which will return a sorted list of the keys. Then, you can write code like:
for key in sorted(myDict):
print key, myDict[key]etc. Note that because of the use of a builtin (i.e. written in C) makes it fast, and the use of the iterator protocol makes it memory efficient. Thus, it should work fine even for large dictionaries.