Premium

Sort Numbers with Array.prototype.sort

By FrontendAtlas Editorial · Updated Feb 1, 2026

Challenge summary

Sort numeric values in either direction while leaving the source array unchanged.

What you'll practice

  • Use numeric comparison rather than default string ordering.
  • Support both ascending and descending order explicitly.
  • Return a new array without mutating the input.

What Premium unlocks

Premium unlocks the runnable workspace, behavioral checks, implementation walkthrough, and edge-case discussion.

Free related practice

Public interview reports: Taro (November 2025), LeetCode Discuss (July 2020) · Datadog frontend interview questions · Amazon frontend interview questions

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

Premium is $24 a month or $99 a year, less in many countries.