+ 1

J.S. why isn't the .sort() working?

On this code I'm trying to play with it and see if I could put it in alphabetical order. But it doesn't seem to be working. https://code.sololearn.com/WWiRzU4h2fbS/?ref=app (I got the code from w3schhool, and it said .sort() is to sort alphabetic...)

12th Jun 2019, 5:51 AM
Ginfio
Ginfio - avatar
2 ответов
+ 13
Pass to the sort method a compare function as parameter with logic what you need arr.sort(compareFunc); And read about lexicographic ordering in it
12th Jun 2019, 6:26 AM
Вап
+ 3
The sorted output is Ginfio,Gordon,Henery,Sololearn,calvin,some-guy If you say this sorting is not working, what is your expected sorting output?
12th Jun 2019, 6:16 AM
Calviղ
Calviղ - avatar