Dsa
Sorting
Easy
Employee Salary Sorting
You are tasked with organizing the salary information of employees in a company. Each employee has a name and a salary. Write a program to sort the list of employees by salary in descending order. If two employees have the same salary, sort them by their names in alphabetical order.
Input:
- The first line contains an integer e (1 ≤ e ≤ 100), the number of employees.
- The next e lines contain an employee's name followed by their salary (a floating-point number).
Output:
- Print the sorted list of employees in the format: "Name Salary".
Example:
Input:
4
John 3000.00
Alice 2500.50
Jane 3000.00
Bob 2000.00
Output:
John 3000.00
Jane 3000.00
Alice 2500.50
Bob 2000.00
Key concepts
sortingtuplesbasic algorithms
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now