json数组排序

//json数组

var menuData1=[

  {"orderid":-10,"text":"主页","title":"个人网站主页","url":"Default.aspx?TeacherID=153","visible":true,"target":"_self"},

  {"orderid":10,"text":"个人新闻","title":"个人新闻","url":"News.aspx?TeacherID=153","visible":true,"target":"_self"},

  {"orderid":5,"text":"发表论文","title":"发表论文","url":"Paper.aspx?TeacherID=153","visible":true,"target":"_self"},

  {"orderid":2,"text":"出版专著","title":"出版专著","url":"Monograph.aspx?TeacherID=153","visible":true,"target":"_self"},

  {"orderid":7,"text":"参与项目","title":"参与项目","url":"Project.aspx?TeacherID=153","visible":true,"target":"_self"},

  {"orderid":8,"text":"个人荣誉","title":"个人荣誉","url":"Prize.aspx?TeacherID=153","visible":true,"target":"_self"},

  {"orderid":1,"text":"发明专利","title":"发明专利","url":"Patent.aspx?TeacherID=153","visible":true,"target":"_self"},

  {"orderid":0,"text":"文件共享","title":"文件共享","url":"FileShare.aspx?TeacherID=153","visible":true,"target":"_self"}

  ];

//进行排序

   menuData1.sort(function(a, b) { return a.orderid > b.orderid ? 1 : -1;} );

 

//如果是对字符或汉字进行排序

menuData1.sort(function(a, b) { return a.localeCompare(b) })
posted @ 2013-04-02 16:39  看看我的眼神  阅读(694)  评论(0编辑  收藏  举报