[Tutor] Reordering a list

Alan Colburn aicolburn@yahoo.com
Fri May 30 13:03:01 2003


Hi all --

I'm working on a program that includes a list,
displayed in order (the list is displayed in a
PythonCard list box but, for purposes of this post,
that's relatively unimportant ... just think of a
standard list). What I'm trying to figure out is how
to be able to rearrange the list at will --
specifically, at the push of a button marked "Up" the
currently highlighted list element will be moved up
one place, and the previous list element will be moved
down one place. 

In other words, if list=["one","two","three"] and the
user selects "two" from the list box (i.e., list[1]),
and clicks the "Up" button, then the list will become
list=["two","one","three"]. 

I've figured out a successful way to do this, but my
procedure is cumbersome -- I know there must be an
easier way ... but I don't know what it is. Any
suggestions?

Thanks, as always -- Al C.

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com