programming faqs interview questions tech technical educational freshers guide preparation interviews hr telephonic
try another color:
try another fontsize: 60% 70% 80% 90%
ProgrammingFAQs

how to sort the array in javascript?

we can sort the array using

we can sort the array using sort() in javascript, by default it sorts the array by ascending order,if you want it in descending order user reverse() function

var myarray=["new york", "california", "ohio"]
myarray.sort() // sorts in ascending order

myarray.reverse() //descending order