Home python строка не найдена

строка не найдена

Author

Date

Category

There is a list of lists:

[[(4, 0.454453), (5, 0.563333), (1, 0.879905)]
[(5, 0.769977), (1, 0.123533), (4, 0.986533)]]

Please tell me how to sort them so that each list is sorted from smaller to more on the first element, for example:

[[(1, 0.879905), (4, 0.454453), (5, 0.563333)]
[(1, 0.123533), (4, 0.986533), (5, 0.769977)]]

Answer 1, Authority 100%

lst = [[(4, 0.454453), (5, 0.563333), (1, 0.879905)], [ (5, 0.769977), (1, 0.123533), (4, 0.986533)]]

either:

[sorted (i) for i in lst]

either:

list (map (Sorted, Lst))

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions