• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Troubleshooting

Why isn’t my array of numbers sorting correctly?

By default, the Array.sort() method sorts alphabetically. If you give it an array of numbers, it converts those numbers to strings and then sorts them alphabetically. According to this procedure, 2 is “higher” than 10,000.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint