Python
#3

Multi-Key Sorting with Lambda Functions in Python

Easy
Interview Question #3

Given a list of client dicts with `name`, `tier` (1 to 3, where 1 is highest), and `revenue`, sort the clients primarily by `tier` ascending, and secondarily by `revenue` descending.

Input Table: clients
3 rows preview
nametierrevenue
Acme Corp150000
Beta LLC280000
Gamma Inc195000
Expected Output Structure3 rows
nametierrevenue
Gamma Inc195000
Acme Corp150000
Beta LLC280000
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us