Ordered list question
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
> element tag. I'm needing these elements in numerical order (from the id).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list