Difference between sort and sorted

0 votes
What is the difference between sort() and sorted() in python? I have seen few code examples and outputs but I don't know the logic. Please explain.
Feb 6 in Python by Disha
13 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

sort() basically works with the list itself. It modifies the original list in place. The return value is None.

sorted() works on any iterable that may include list, dictionary and so on. It returns another list and doesn't modify the original list.

answered Feb 6 by Omkar
• 66,880 points

Related Questions In Python

0 votes
1 answer

What's the difference in Qt between setVisible, setShown and show/hide

show() is just a convenience function for ...READ MORE

answered Apr 17, 2018 in Python by anonymous
603 views
0 votes
1 answer

What is the difference between list and tuple?

Lists are mutable(values can be changed) whereas ...READ MORE

answered May 4, 2018 in Python by aayushi
• 750 points
1,096 views
0 votes
1 answer

Difference between '==' and 'is'

'==' checks for the equality of the ...READ MORE

answered May 14, 2018 in Python by Nietzsche's daemon
• 4,260 points
12 views
0 votes
1 answer

Difference between pop and delete methods

I think you mean del() and not ...READ MORE

answered Jun 25, 2018 in Python by Hamartia's Mask
• 1,580 points
20 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
54 views
+4 votes
6 answers
+6 votes
4 answers

Python and Pygame: Difference

Python is a programming language. PyGame is a ...READ MORE

answered Oct 24, 2018 in Python by Priyaj
• 56,140 points
68 views
+1 vote
2 answers

Measuring the distance between pixels on OpenCv with Python

You can try this: Mat pts1(nPts, 1, CV_8UC2), ...READ MORE

answered Aug 24, 2018 in Python by Omkar
• 66,880 points
2,083 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.