Sort Posts by Engagement
Medium📝 Description
Sort posts by total engagement (likes + comments) in descending order.
Input Format
[{"post": str, "likes": int, "comments": int}]
Output Format
[{"post": str, "likes": int, "comments": int}] (sorted)
Constraints
1 ≤ number of posts ≤ 10^5, 0 ≤ likes, comments ≤ 10^6
🔍 Sample Input
[{"post": "A", "likes": 10, "comments": 2}, {"post": "B", "likes": 5, "comments": 10}]
✅ Sample Output
[{"post": "B", "likes": 5, "comments": 10}, {"post": "A", "likes": 10, "comments": 2}]
Code Editor
Please login to run and submit code.
Results
Suggested Solution
Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run