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?
   
  Thanks,
Sara
  

Alan Gauld <[EMAIL PROTECTED]> 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.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to