_sortBy用法

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>HTML5 Canvas绘制文本文字入门示例
    </title>
</head>
<body>
<script src="lodash.js"></script>
<script>
    var b = [
        {name:"222",age:22},
        {name:"sdfs22",age:2},
        {name:"24322",age:12},
        {name:"22fds",age:42}
    ];
    var a = _.sortBy(b,function(o){return o.age});
    console.log(a);
//也可以这样用
var b = _.sortBy(b,"age"){
console.log(a)
}
</script> </body> </html>

针对对象数组排序,

posted @ 2016-02-24 18:08  挥刀  阅读(2312)  评论(0编辑  收藏  举报