Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save venelrene/da7d558f0c2e61d797cdbc917c8e8848 to your computer and use it in GitHub Desktop.
Save venelrene/da7d558f0c2e61d797cdbc917c8e8848 to your computer and use it in GitHub Desktop.
Suzuki needs help lining up his students! Today Suzuki will be interviewing his students to ensure they are progressing in their training. He decided to schedule the interviews based on the length of the students name in descending order. The students will line up and wait for their turn. You will be given a string of student names. Sort them an…
function lineupStudents(names){
return names.trim().split(" ").sort((a,b) =>
a.length - b.length || a.localeCompare(b)).reverse()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment