可能重复:
Sorting objects in an array by a field value in JavaScript
用field1,field2或field3对“行”进行排序的最佳方法是什么?
如果field1,field2或field3是非数字值(字符串或日期),如何才能对这些不同的数据类型进行排序呢?
var Id = 0;
var rows = new Array(); // I want to sort this array by either field1, field2, or field3
rows[0] = (1, 3, 5);
rows[1] = (-2, 4, -6);
function Row(field1, field2, field3) {
this.RowId = Id++;
this.Field1 = field1;
this.Field2 = field2;
this.Field3 = field3;
}