Algorithms and Data Structures · Junior · Question 37 of 75

What does a stable sort guarantee?

Explanation

Stability matters when you sort by several keys: sort users by name, then stably by age, and users of the same age stay ordered by name. Array.prototype.sort has been required to be stable since ES2019.

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 37

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz