sort()

noun

say it: “SORT” /sɔːrt/

The JavaScript array method that puts items in order, changing the array itself.

What does sort() do in JavaScript?

sort() — Puts a list in order, changing the list itself.

const scores = [10, 2, 7];
scores.sort((first, second) => first - second);

In a sentence

  • “names.sort() put the names in alphabetical order.”

Level: Journeyman · More JavaScript terms at this level

Updated

In other subjects