Loading...

The Value Sorter

A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
easy
Seniority
junior

Problem

Our reporting service needs to rank metrics by their values. Write a function called sort_by_value that takes a dictionary of string keys and numeric values and returns a list of (key, value) tuples sorted by value in descending order. If two values are equal, sort those keys alphabetically.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.