function test()
{
var json = {"city": [
{"id": "1", "name": "北京", "sort": "1"},
{"id": "2", "name": "上海", "sort": "3"},
{"id": "3", "name": "江苏", "sort": "4"},
{"id": "4", "name": "安徽", "sort": "2"}
]};
//$.each(json.city, function(i) {
// alert(json.city[i].id+" " +json.city[i].name+" sort:"+json.city[i].sort);
//});
json["city"].sort(function(a,b){
return a["sort"]>b["sort"]?1:a["sort"]==b["sort"]?0:-1
});
$.each(json.city, function(i) {
alert(json.city[i].id+" " +json.city[i].name+" sort:"+json.city[i].sort);
});
}
$(function(){
test();
});