Can anyone explain difference between "sort" and "sorted"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone explain difference between "sort" and "sorted"?

18th Apr 2019, 5:48 PM
Dileep Patcha
Dileep Patcha - avatar
2 Answers
+ 4
In Python? Sort is method for example of list so it will sort given list list.sort(). Sorted is function which sorts any sequence and return sorted sequence new_list = sorted(list)
18th Apr 2019, 6:02 PM
Hubert Dudek
Hubert Dudek - avatar
+ 2
I read an article recently where the author compared the two with respect to time to complete.The sorted method was faster than sort. Note this was with respect to Python.
19th Apr 2019, 1:03 AM
Jim