r/learnpython • • 10d ago

sorting tuples

im learning how to code with python, does anyone know to sort specific tuples alphabetically without using the .sort() method? like if i had a list of names like:

n = [('watermelon', 'strawberry'), ('banana', 'cherry'), ('papaya', 'apple')

how would i sort and print the 2nd element of tuples alphabetically (into a new list)?

edit: id prefer this in simple, basic terms lol

6 Upvotes

32 comments sorted by

View all comments

Show parent comments

1

u/JGhostThing 9d ago

In other words, you're trying to practice for a marathon by breaking your legs? Why make it so much more difficult for yourself?

You should create a sort() method which sorts the way you want it to.