Possible Duplicate:
Sorting objects in an array by a field value in JavaScript
What is the best way to sort "rows" by either field1, field2, or field3?
What if field1, field2, or field3 is a non-numeric value (string or date), how can I make it possible to sort by these different data types?
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; }