Ordered list question

Dan Stromberg drsalists at gmail.com
Sun Jul 17 21:37:26 CEST 2011

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, <jyoung79 at 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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110717/2b16d27d/attachment.html>

More information about the Python-list mailing list