js中数组排序的方法

2025-12-05 16:38:29
推荐回答(1个)
回答1:

//原生方法sort,例子:
var a = [ 5, 4, 1, 2, 3 ];
a.sort( function( a, b ) {
    return a - b;
} );