sorted() vs .sort(): What Interviewers Are Actually Watching

Concepts covered: pyLambda, pyListCopy, pyListSort, pyModules

Here's something most tutorials won't tell you: interviewers at top companies don't care if you know that sorted() returns a new list and .sort() is in-place. Every candidate knows that. What they're watching is whether you reach for the right one given the context, and whether you can explain why you chose it. The Core Syntax The key= Parameter: the Heart of the Pattern The key= parameter is where custom sorting lives. It's a function that takes one element and returns a value Python uses for comparison. The critical insight: Python calls your key function exactly once per element, caches the results, and uses those cached keys for all O(n log n) comparisons. This is much cheaper than a comparator function that gets called O(n log n) times. Interviewers who know their Python internals wil

About This Interactive Section

This section is part of the Custom Sorting: Beginner lesson on DataDriven, a free data engineering interview prep platform. Each section includes explanations, worked examples, and hands-on code challenges that execute in real time. SQL queries run against a live database. Python runs in a sandboxed Docker container. Data modeling problems validate against interactive schema canvases. All content is framed around what data engineering interviewers actually test at companies like Meta, Google, Amazon, Netflix, Stripe, and Databricks.

How DataDriven Lessons Work

DataDriven combines four interview rounds (SQL, Python, Data Modeling, Pipeline Architecture) with adaptive difficulty and spaced repetition. Easy problems get harder as you improve. Weak concepts resurface until you master them. Your readiness score tracks progress across every topic interviewers test. Every lesson section ends with problems you solve by writing and running real code, not by picking multiple-choice answers.