Sorting strings in Jquery

Goud.Kv
Posted by Goud.Kv under jQuery category on | Points: 40 | Views : 300
Below code snippet explains how to do sorting in JQuery.

<script>

$(document).ready(function(){
var books = [ “Adventure”,”Educational”,”Comedy”];
books = books.sort();
$(“#mydiv”).html(list.join(“”));
});

</script>


The output of the above code is..,

Adventure
Comedy
Educational

Because sorting is done in Alphabetical order in JQuery.

Comments or Responses

Login to post response