List Sorted Increasing Order | List In Python | Python Exersice | Tuple in Python #shorts #ytshorts

preview_player
Показать описание
x = ["subscribe","and","learn","more"]
write code to get the following output
'subscribe and learn more'

Write a Python program to get a list, sorted in increasing order by the last element in each tuple from a given list of non-empty tuples.

Sample List : [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]

Expected Result : [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]

new video for python programming
python code for problem solving approach.
- python for beginners
- learn python in simple way.
- first clear basic concepts.
- solve more problems and consistent practice.

List in Python
Tuple in Python
list in increasing order.
python programming for beginners
python programming examples
python List
learn python

#shorts #ytshorts #python # pythoncode #education #tutorial

Рекомендации по теме
Комментарии
Автор

So, nested loops, and worst case O(n ** 2), and generally O(nm). Iterative algorithm suits here, while recursion would not be necessary. Thinking about another solution...

sergeiivanov
Автор

Bubble sort? Then, we already know algorithms such as Timsort, double pivot quick sort and other iterative+recursive sorting algorithms, so optimization is seen. Thank you for the video!

sorted(l, key = lambda x: x[1])

sergeiivanov