Skip to content

Instantly share code, notes, and snippets.

@dan-laskowski
Created May 5, 2021 12:06
Show Gist options
  • Save dan-laskowski/9c18cfff66cc225ef80a4d4f6acad18a to your computer and use it in GitHub Desktop.
Save dan-laskowski/9c18cfff66cc225ef80a4d4f6acad18a to your computer and use it in GitHub Desktop.
[Sort an array containing numbers] #javascript #js #array #sort #number
// Sort an array containing numbers
const sort = arr => arr.sort((a, b) => a - b);
sort([1, 5, 2, 4, 3]);
// Result: [1, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment