我有一个装满JSON对象的数组,并且我正在尝试通过JSON对象内的索引键对该数组进行排序。
var array = [{fullName: "John Doe", firstName: "John", surName: "Doe", numberInLine: 3}, {fullName: "Jane Wells", firstName: "Jane", surName: "Wells", numberInLine: 2}, {fullName: "Kim Schmidt", firstName: "Kim", surName: "Schmidt", numberInLine: 1}]
我将如何对其进行排序,以使结果看起来像这样:
var array = [{fullName: "Kim Schmidt", firstName: "Kim", surName: "Schmidt", numberInLine: 1}, {fullName: "Jane Wells", firstName: "Jane", surName: "Wells", numberInLine: 2}, {fullName: "John Doe", firstName: "John", surName: "Doe", numberInLine: 3}]