Sort CSV Data by Column in Descending Order Using Pandas
Beginner Mode

Start your terminal to use beginner mode.

Scenario

A CSV file contains employee data that needs to be sorted by salary for analysis and reporting purposes.

Task

Complete the Python script at /home/interview/sort_data.py to read /home/interview/data.csv, sort the rows by the salary column in descending order, and save the result to /home/interview/sorted_data.csv.

Example

Input (data.csv):

id,name,department,salary
1,John Doe,Engineering,75000
2,Jane Smith,Sales,95000
3,Bob Johnson,HR,55000

Expected output (sorted_data.csv):

id,name,department,salary
2,Jane Smith,Sales,95000
1,John Doe,Engineering,75000
3,Bob Johnson,HR,55000

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.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →