如下:

<script type="text/javascript">
var ary = [
{name: "刘艺", age: "48岁"},
{name: "阿布", age: "48岁"},
{name: "王三", age: "32岁"},
{name: "张二", age: "29岁"},
{name: "李一", age: "49岁"},
{name: "李三", age: "18岁"},
{name: "朱朱", age: "6岁"}
];
//把数组中的每一项的对象按照age的值进行排序
//对于纯数字的,我们用-,只要不是纯数字,我们用localeCompare
ary.sort(function (a, b) {
//console.log(a);//每一次循环的当前项
//console.log(b);//每一次循环的下一项
return a.name.localeCompare(b.name);
// return parseFloat(a.age) - parseFloat(b.age);
});
console.log(ary);
</script>