If you need "read everything, then sort once", then a dictionary (or
collections.defaultdict if you require undefined's) and a single sort at the
end is probably the way to go.

If you truly need an ordered datastructure (because you're reading one
element, using things sorted, reading another element, using things sorted),
then you're better off with a treap (good average case time) or red-black
tree (decent average case time, but without as much fluctuation).

On Sun, Jul 17, 2011 at 9:28 AM, <jyoun...@kc.rr.com> wrote:

> I'm currently working on a project where I'm looping through xml elements,
> pulling the 'id' attribute (which will be coerced to a number) as well as
> the
> element tag.  I'm needing these elements in numerical order (from the id).
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to