字符串的排序
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>数组排序</title><script>var arr = ['fliar', 'asdf', 'dfe', 'loii', 'yhhl'];arr.sort();alert(arr);</script>
</head><body></body></html>
数字的排序
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>Document</title><script>var arr = [22, 23, 444, 11, 2123, ]arr.sort(function(num1, num2) {return num1 - num2;})alert(arr);</script>
</head><body></body></html>