6. Insert into Sorted Leaderboard

Write a function `insertSorted` that takes an array of leaderboard records and a new record, and inserts the new record into the array while maintaining descending order by score. If two scores are equal, the new record should appear after existing ones.

Examples:

Input: records = [{ id: 1, username: "Alice", score: 100 }, { id: 2, username: "Bob", score: 80 }], newRecord = { id: 3, username: "Charlie", score: 90 }
Output: [{ id: 1, username: "Alice", score: 100 }, { id: 3, username: "Charlie", score: 90 }, { id: 2, username: "Bob", score: 80 }]
Explanation: Charlie has higher score than Bob but less than Alice.
SolutionJavaScript
Test Results
Click "Run Code" to test your solution