Tutorial #14: sort() method and sorted() function: How are they different? _ Python for Beginners

preview_player
Показать описание
The sort() method is associated with Python list object. When called on a list, it sorts the list by making changes directly to the list without returning any value. Rather, it changes the original list.

If you want a function to return the sorted list rather than change the original list, use sorted() function instead.
sorted() function is a built-in function. When called, it creates a new list to store sorted values without making changes to the original list.
-------------------------
Python Tutorial for Beginners
Python Coding for Beginners
Python Programming for Beginners
Learn Python by Building Projects
Python Exercises and Practical Examples with solutions
Practice Python Online with solution
How to write a Python program
Python Programming Data Structure and Algorithm
Python Problem Solving
Python Game Tutorial
Python Game Programming
Python Game Development
Python Tips and Tricks

tag:
Which is better sort or sorted in Python?
Which is better sort or sorted?
What is difference between sort () and sorted () function explain with example?
What is sorted () in Python?
python sort vs sorted performance
How do you sort something in Python?
What does sort () do in Python?
What is the sort () method?
How does sort () sort in Python?
How to Use sorted() and sort() in Python
How to Sort a List in Python Using the sort() Method
How sorted () can be used with list in Python?
What does sorted () do in Python?
python sort list of strings with numbers
Рекомендации по теме
Комментарии
Автор

The simplest difference between sort() and sorted() is: sort() changes the list directly and doesn't return any value, while sorted() doesn't change the list and returns the sorted list.

makeeverydayezday
Автор

Thanks bro, only actual programmers watch channels like yours.

passportbro
Автор

spent a lot of time trying to get this before, and you explained it in less than 6 minutes. great!!!

tombray
Автор

thank you, you have explained everything beautifully in a systematic manner

petergrivas
Автор

Oh well that's why I run the sorted() function the other day and nothing happened. It must be assigned to a variable, not a function call alone! Great tutorial mate!

joomla
Автор

Awesome video, thank you. I will add your other video that talks about sort() method and sorted() function make it a little nebulous as far as when the -1 would be used but I still like to have it in the tool belt arsenal.

tienphongtran