$(document).ready(function () {
//对json进行降序排序函数
var colId="age"
var desc = function(x,y)
{
return (x[colId] < y[colId]) ? 1 : -1
}
//对json进行升序排序函数
var asc = function(x,y)
{
return (x[colId] > y[colId]) ? 1 : -1
}
var arr2 = [
{name:"kitty", age:12},
{name:"sonny", age:9},
{name:"jake", age:13},
{name:"fun", age:24}
];
document.writeln("按age进行升序排序:<br>");
arr2.sort(asc); //升序排序
document.writeln(JSON.stringify(arr2));


document.writeln("<br>按age进行降序排序:<br>");
arr2.sort(desc); //降序排序
document.writeln(JSON.stringify(arr2));

});






div排序
$("#formData li").each(function(){ 
$(this).prependTo("#formData ul"); 
})

  

相关文章:

  • 2021-10-06
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案