Sort array in ascending or descending order using sort function
Array :
let k=[1,3,11,2,33,22]
k.sort()
Result :
[1,11,2,22,3,33]
let k=[1,3,11,2,33,22]
k.sort()
Result :
[1,11,2,22,3,33]
Here the array just sorted based on the ASCI values, so how to make it such way that it can return the array in ascending sort order.
Subscribe to:
Posts (Atom)
