I'm not sure if there's a way to submit responses 'live' or whether it's better to respond to subthreads at once or together, so I'll err on the side of discretion and just send one response. Thanks to each of you who tried to help me. I've responded individually below. To summarize the discussion so far: I wondered if there was a decent way to sort a list that contained two lists, where each could be distinguished based on the list's sequence and the elements' data characteristics. As a subsidiary question, I wondered if there was a data structure I should aspire to put the data into once I had it sorted. In response to the first question: the consensus seems to be that there is no good way to sort a non-alternating one-to-many list like this, so my strategy of deriving the index numbers of every item, as awkward as it appears, may actually be the best approach. In response to the second: a pickle, a dictionary, a database, and a tuple with a sublist were all proposed. The choice seems somewhat arbitrary, but on the bright side, I suppose that also confirms that I have a lot of flexibility in what I choose. Specific responses: Steven, I apologize for using 'reply,' I've never used a mailing list before and didn't understand what would happen. Is there some online forum where I could post a message directly rather than mailing it in? I see that other people are somehow responding to my message from the more real-time updates I can get on activestate, but I don't know how they are doing it since I haven't received the mailing yet that would include my message and its responses. If my list had a million books in it and 10 million page numbers, would the approach I've outlined in my initial post be the best for sorting them? Like David and Eric you've given me some good input on a data structure to use. If I understand you right, you'd advocate using a tuple of the books, bookmarks, where the bookmarks themselves are sublists. David, Yes, I agree it would be much better to store the data in a different manner. The problem is that I'm not the creator of the data. Maybe you realize that and are just suggesting the database structure rather than a dictionary or a pickle, once I get my sorting accomplished? If the book example is confusing how about this. Say you discovered a bunch of data in a secret code document. You know the sequence of the data relates the elements to each other. You also know there are just two elements and that the sequence is a straightforward function of say, integers to letters. So the data you've discovered looks like: A 2 3 B 4 7 5 9 1 C 3 2 1 0 0 4 D 3 3 32 44 ... Once I've sorted the data, I am curious how to best store it (and why), and your answer does pertain to that-- use sql-- but I am also curious if there's a less arcane approach than the one I'm using to try to do the initial sorting. Any thoughts, given that I can't fix the way the data arrives? Thanks for the database idea regardless. Eric, I appreciate your input though I'm hard-pressed to find its applicability. It may be useful as a way to store my data for this or any number of other programs though, and that was a helpful article about the pickling process. I don't know if pickle has any built-in methods for relating data to other data. I'd imagine that if I were designing the data input process, rather than just taking data that exists and trying to process it, I'd probably go with a database for a situation like this. Then I'd have a more explicit system for referring each value to other values through records, rather than having to infer them as I'm doing. Regardless, I'm often in the same position of trying to be helpful without knowing how, and I sincerely do appreciate the attempt. It creates a general atmosphere of friendliness, which is so much better than being told I'm an idiot :)! Lingering Questions: Anyone have a rationale for choosing one of the data structures proposed? Anyone have a better way to do the sorting than the process I outlined in my first post (a. identify the elements. b. make a list of one of the element groups. c. get the index numbers of that group in the broader list. d. list the other elements as indexes falling between the first group's indexes. e. reorganize the data into a more logical form) Thanks again to everyone who responded! Soren
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor