var as = [
as
//自定義按照數字排序
function sortByNum(a
return parseInt(a)
}
as
//按照對象來排序
//定義一個person對象
function Person(name
this
this
}
var p
var p
var p
var p
var ps = [p
function sortByName(obj
if(obj
else if(obj
else{return
}
function sortByAge(obj
return obj
}
ps
ps
以上排序帶來的問題就是假設對象有很多屬性
function sortByProperty(proName){
var sortFun = function(obj
if(obj
else if(obj
else {return
}
return sortFun;
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19844.html