Javascript examples for jQuery:Array
Sort an array of objects in ascending order of number
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(window).load(function(){/*from ww w .j a v a2s.c o m*/ function sortAscending(data_A, data_B) { return (data_A - data_B); } var array =[ 9, 10, 21, 46, 19, 11] array.sort(sortAscending) console.log(array); }); </script> </head> <body> </body> </html>