New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Can anyone explain difference between "sort" and "sorted"?
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)
+ 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.