PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Python · Theory

list.sort()

← All stacks

Theory

254/268

list.sort()

list.sort() works on a list. Lists can change. Many methods update the same list (append, pop, sort, insert) instead of returning a new one.

list.sort() — output — [70, 80, 90]. sort is in place. sorted() would return a new list.

Trap for list.sort() — append([1, 2]) nests a list. extend([1, 2]) adds 1 and 2. sort vs sorted is a viva favourite.

Diagram
index →  0       1       2
  list  → [Asha,  Ravi,  Neha]
Exam tip

In place or new list? Say it first, then one example.

Example

# list.sort()
a = [70, 90, 80]
a.sort()
print(a)

list.sort() — output: [70, 80, 90]. sort is in place. sorted() would return a new list.

Short notes

  • Deflist.sort() changes or reads a list.
  • Rulelist.sort() — many list methods are in place.
  • Difflist.sort() — sort vs sorted, in place vs new list.
  • Traplist.sort() — append(list) nests a list; extend adds items.

Questions

1

Explain list.sort() as if you are teaching a junior — definition, then one tiny script.

2

What does the example print, and why?

3

What mistake do freshers make with list.sort()?

Previous← list.index()Nextlist.copy() →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.