Interview practice question
Sorting objects by multiple fields
Frontend Engineering · JavaScript Core · Intermediate
You need to sort a list of users by last name, then by first name. How do you do it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Comparator returning first non-zero comparison.
- localeCompare for strings.
- Stable sort guaranteed in modern JS.
- Copy before sort.
- Intl.Collator for performance.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.