← HALL

Lexicographical Array Sort Bug

MEDIUM
+250 XP REWARD ⏱ Limit: 10m
// MISSION BRIEFING //

ANOMALY DESCRIPTION

A leaderboard ranking utility calls Array.prototype.sort() without arguments. Scores [100, 25, 5, 2000] end up sorted as [100, 2000, 25, 5]! Supply a proper comparison callback to sort in ascending numerical order.

SPECIFICATION SUITE

Mixed numbers
Input: [100, 25, 5, 2000]
Expected: [5, 25, 100, 2000]
Negative integers
Input: [-10, 5, -2, 0]
Expected: [-10, -2, 0, 5]
Already sorted [PROTECTED TEST]
Evaluation logic hidden to prevent hardcoding.

RADAR HINTS

Hint #1 (Click to decrypt)

Pass a comparator function (a, b) => a - b to the sort method.

solution.js UTF-8 • JAVASCRIPT
STATIC ANALYSIS CONSOLE Ready for dispatch

Press "VERIFY & SUBMIT" or Ctrl+Enter to evaluate your patch.