Ordered list question

jyoung79 at kc.rr.com jyoung79 at kc.rr.com
Mon Jul 18 06:12:24 CEST 2011


Thank you Chris, Dan and Thomas for your replies.  I really appreciate your 
insight, and I will look into the information you have given me.  

Dan,
I've never heard of a "treap" or "red-black tree", so I'll be interested to 
research these.

Thomas,
Thanks very much for giving me further knowledge on xml and ECMAScript (I 
continually get this confused with javascript!).  In this project, I'm 
using Adobe InDesign with javascript (which is probably ECMAScript).  For 
xml parsing, it looks like Adobe uses the E4X XML Object, so I'm trying 
to go by those rules.  I'm new to xml, so I might be doing this all the 
wrong way.  Currently I'm looping through each element (in the XML Object), 
knowing what to do by the element type name and attributes given me.  In 
certain circumstances I'm needing things ordered by the id attribute, and 
as mentioned the elements will always be a different set of data.  I'm 
looking for a quick way to do this instead of a bubble sort.  Further 
down the line I'm hoping to incorporate Python and will probably use the 
ElementTree module.

I did have a couple of questions from your reply though:

> var o = {};
>   o[5] = "price";
>   o[1] = "copyright";
>   o[3] = "address";

> Then:

>   for (var prop in o)
>   {
>     /* get prop or o[prop] */
>   }

If using this object instance, how were you thinking of putting this in 
index order?  Remember, I'm needing the original items "price", 
"copyright" and "address" in numerical order by what the id attributes 
are.  So I'd need it to end up being in this order - ["copyright", 
"address", "price"].

> The variable name `x' should also be reserved for non-counters, e. g. object 
> references.  Use i, j, k, and so forth in good programming tradition here 
> instead.

Can you share a website that goes into more detail on this good variable 
naming?  By the way, thanks for all the links you shared… I have bookmarked 
all of these - they look incredibly useful!


Thanks again for the help!

Jay




More information about the Python-list mailing list