[Tutor] Bundle help!

Sara Johnson sarliz73 at yahoo.com
Mon Jul 9 18:54:13 CEST 2007

Sorry to be so confusing.  Just realized a dumb mistake I made.  It doesn't need to be resorted alphabetically and numerically.  I need one list alphabetical and one numerical.
   (Alphabetical) List 1, [('Fred', 20), ('Joe', 90), ('Kent', 50), ('Sara', 80)]
  (Numerical) List 2,  [('Fred', 20), ('Kent', 50), ('Sara', 80) ('Joe', 90)]
  It looks like these are appended together, but to re-sort, how do I (not sure if this is a word) "unappend" them?

Alan Gauld <alan.gauld at btinternet.com> wrote:
    "Sara Johnson" wrote

>>Use append() to add more data, then sort again to get it in order:
>>>>In [6]: data.append(('Joe', 90))
>>>>In [7]: data.sort()
>>>>In [8]: data
>>>>Out[8]: [('Fred', 20), ('Joe', 90), ('Kent', 50), ('Sara', 80)]
> What happens if I need to sort alphabetical and numerically?

You can supply your own comparison function to the sort routine.
You can also just specify the key to sort by for simple cases.

> I'm taking the original list and the original values
> i.e., ('Fred', 20), ('Joe', 90), ('Kent', 80)... and switching it 
> so that it reads in both ways...
> List 1, [('Fred', 20), ('Joe', 90), ('Kent', 50), ('Sara', 80)]
> List 2, ('Fred', 20), ('Joe', 50), ('Kent', 80), ('Sara', 90)]

But you lost me here. You seem to be switching the values
in the tuples around and its not clear to me by what criteria.

Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070709/74fea07f/attachment.html 

More information about the Tutor mailing list