Sort Avro Employee Records by Salary
Beginner Mode
Start your terminal to use beginner mode.
Scenario
An Avro file contains employee records that need to be analyzed. The data must be sorted to identify salary distribution across the organization.
Task
Write a Python script at /home/interview/sort_employees.py that reads /home/interview/employees.avro, sorts all records by salary in descending order (highest to lowest), and saves the sorted data as JSON to /home/interview/sorted_employees.json.
Note: The fastavro library is already installed.
Example
Expected output format in /home/interview/sorted_employees.json:
[
{
"id": 45,
"name": "John Smith",
"department": "Engineering",
"salary": 150000,
"hire_date": "2020-03-15",
"is_active": true
},
{
"id": 89,
"name": "Jane Doe",
"department": "Sales",
"salary": 145000,
"hire_date": "2019-07-22",
"is_active": true
},
...
]
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
GitHub