Premium

Sort Numbers with Array.prototype.sort

By FrontendAtlas Team · Updated Feb 1, 2026

Implement a function sortNumbers(arr, ascending = true) that returns a new array of numbers sorted numerically in ascending or descending order. The original array must not be mutated, and you should use Array.prototype.sort() correctly with a compare function. Concepts: arrays, sorting.

Challenge preview

Sort Numbers with Array.prototype.sort: Implement a function sortNumbers(arr, ascending = true) that returns a new array of numbers sorted numerically in ascending or descending order. The original array…. Expect arrays and sorting decisions under easy level constraints.

Premium unlocks

  • Full editor workflow with starter files, tests, and solution context.
  • Edge cases, common mistakes, and complexity notes for the interview discussion.
  • Progress tracking once you unlock and complete the challenge.

Free warm-up options

Upgrade to FrontendAtlas Premium to unlock this challenge. Already upgraded? Sign in to continue.