function sort() { var ary = [2, 1, 0.4, 2, 0.4, 0.2, 1.5, 1, 1.1, 1.3, 1.2, 0.2, 0.4, 0.9]; return ary.sort(function(a, b) { console.log(a,b,'rererererer') return a - b; }); } alert(sort());