var
points
=
[
40
,
100
,
1
,
5
,
25
,
10
]
;
points.
sort
(
function
(
a
,
b
)
{
return
b
-
a
}
)
;
fruits输出结果:
100,40,25,10,5,1
尝试一下 »
数字排序 (字母和降序):
var
fruits
=
[
"Banana"
,
"Orange"
,
"Apple"
,
"Mango"
]
;
fruits.
sort
(
)
;
fruits.
reverse
(
)
;
fruits输出结果:
Orange,Mango,Banana,Apple
尝试一下 »
JavaScript Array 对象