# Sort the list [4, 2, 7, 1, 3, 7, 2] and find all duplicates by comparing adjacent elements

Canonical URL: <https://datadriven.io/problems/sort-the-list-4-2-7-1-3-7-2-and-find-all-duplicates-9eb4854c>

Domain: Python · Difficulty: medium

## Problem

Sort the list [4, 2, 7, 1, 3, 7, 2] and find all duplicates by comparing adjacent elements. Print the sorted list of duplicates.

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/sort-the-list-4-2-7-1-3-7-2-and-find-all-duplicates-9eb4854c)
- [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.