Number Guessing Game - CA03
Objective Retrieve leaderboard records from the database Arrange records based on difficulty level and number of attempts Data Structure Each record in the leaderboard contains: Name Difficulty lev...

Source: DEV Community
Objective Retrieve leaderboard records from the database Arrange records based on difficulty level and number of attempts Data Structure Each record in the leaderboard contains: Name Difficulty level Attempts count Approach Collect all leaderboard entries Convert difficulty levels into comparable values Apply sorting logic using both difficulty and attempts Difficulty Priority To ensure proper ordering: Easy is considered lowest Medium is next Hard is highest This helps in comparing difficulty levels during sorting. Sorting Logic Compare two entries First check difficulty level If difficulty is same, compare attempts Swap positions if required Repeat until the list is sorted Code (Python) ```python id="lb32x1" leaderboard = [ {"name": "Alice", "difficulty": "Medium", "attempts": 5}, {"name": "Bob", "difficulty": "Easy", "attempts": 3}, {"name": "Charlie", "difficulty": "Hard", "attempts": 7}, {"name": "David", "difficulty": "Easy", "attempts": 6} ] difficulty_rank = {"Easy": 1, "Medium