Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Sorting algorithms

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Sorting algorithms

Sort an Array

intermediatelayer B7 · Sorting algorithms5 tests

Sort nums into ascending order and return it, using an algorithm that runs in O(n log n) time.

  • You may not call Array.prototype.sort
  • Quadratic algorithms — bubble, insertion, selection — are not acceptable; the tests use arrays large enough to notice
  • Heap sort is a good fit because it sorts in place with O(1) extra space; merge sort would also qualify
  • Duplicates, negatives, an empty array and a single element must all work

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen