Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Sort a list of lists

Avatar of dfernan
dfernanFlag for United States of America asked on
3 Comments1 Solution1885 ViewsLast Modified:
if i have a list of lists like this one: (the one i have is obviously much larger but this is the idea):
new = [['dog',2],['cat',5],['bye',1]]
how can i sort it according to the numbers on the second column, i.e., new[0][1]=2....?
i.e., new.sort should become: new.sort(sthg) = [['bye',1],['dog',2],['cat',5]]

How can i access all the numbers in the second column together like it was a vector?
i.e., new[sthg][sthg] = [2,5,1]

How would you sort it alphabetically up/down?
i.e., alphabetically up: new.sort should become: new.sort(sthg) = [['bye',1],['cat',5],['dog',2]]
i.e., alphabetically down: new.sort should become: new.sort(sthg) = [['dog',2],['cat',5],['bye',1]]

Another basic question:
if i have a list L, L[:] means what?????

I am a newbie in python...

Thanks for the help,

Avatar of Roger Baklund
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers