在数组的一个属性上按字母顺序对数组中的对象进行排序
假设您有一个这样的JavaScript类 var DepartmentFactory = function(data) { this.id = data.Id; this.name = data.DepartmentName; this.active = data.Active; } 假设您然后创建了该类的许多实例并将它们存储在数组中 var objArray = []; objArray.push(DepartmentFactory({Id: 1, DepartmentName: 'Marketing', Active: true})); objArray.push(DepartmentFactory({Id: 2, DepartmentName: 'Sales', Active: true})); objArray.push(DepartmentFactory({Id: 3, DepartmentName: 'Development', Active: true})); objArray.push(DepartmentFactory({Id: 4, DepartmentName: 'Accounting', Active: true})); 因此,我现在将有一个由创建的对象数组DepartmentFactory。我将如何使用该array.sort()方法对对象数组进行排序DepartmentName每个对象属性? 该array.sort()方法在对字符串数组进行排序时效果很好 var myarray=["Bob", "Bully", …