var points = [ 40 , 100 , 1 , 5 , 25 , 10 ] ;
points. sort ( function ( a , b ) { return b - a } ) ;

points 输出结果:

100,40,25,10,5,1
尝试一下 »

数字排序 (字母和降序):

var fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ] ;
fruits. sort ( ) ;
fruits. reverse ( ) ;

fruits 输出结果:

Orange,Mango,Banana,Apple
尝试一下 »

Array 对象参考手册 JavaScript Array 对象

  • #0
  •