# Demonstrate the difference between sort() and sorted()

Canonical URL: <https://datadriven.io/problems/demonstrate-the-difference-between-sort-and-sorted-give-63123dbe>

Domain: Python · Difficulty: medium

## Problem

Demonstrate the difference between sort() and sorted(). Given nums = [5, 2, 8, 1]. First use sorted() to create a new sorted list and print it. Then print the original nums to show it is unchanged.

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/demonstrate-the-difference-between-sort-and-sorted-give-63123dbe)
- [Python Interview Questions](https://datadriven.io/python-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.