Saved Bookmarks
| 1. |
What Is Difference Between Sorting String Array And Sorting Numerical Array In Jquery? |
|
Answer» The sort method is used to sort any array elements. It sorts the string elements ALPHABETICALLY. For example $(document).READY(FUNCTION(){ var mylist = [ “APPLE”,”Orange”,”BANANA”]; mylist = mylist.sort(); $(“#mydiv”).html(list.join(“”)); });It will give following output Apple Now we declare a numerical array and use sort() method to sort its elements. $(document).ready(function(){ var mylist = [ “20”,”3””100”,”50”]; mylist = mylist.sort(); $(“#mydiv”).html(list.join(“”)); });It will give following output 100 The sort method is used to sort any array elements. It sorts the string elements alphabetically. For example It will give following output Apple Now we declare a numerical array and use sort() method to sort its elements. It will give following output 100 |
|