I have an array of objects similar in design as listed below. I would like to sort this array first by by the ClassName (alphabetically), then by the StartDate, but I want to preserve the initial sorting. I understand I can likely use sort() to accomplish this but I'm not sure how to preserve the initial sorting w/o breaking the original array into smaller groupings.
var objArray = [
{
ClassName: "Excel",
Location: "Kansas City",
StartDate: "2/1/2016",
EndDate: "6/2/2016,"
},
{
ClassName: "Outlook",
Location: "Kansas City",
StartDate: "1/1/2016",
EndDate: "5/2/2016,"
},
{
ClassName: "Excel",
Location: "Kansas City",
StartDate: "3/1/2016",
EndDate: "7/2/2016,"
}
];
Ideally based on the data above I'd end up with something like this:
var objArray = [
{
ClassName: "Excel",
Location: "Kansas City",
StartDate: "2/1/2016",
EndDate: "6/2/2016,"
},
{
ClassName: "Excel",
Location: "Kansas City",
StartDate: "3/1/2016",
EndDate: "7/2/2016,"
},
{
ClassName: "Outlook",
Location: "Kansas City",
StartDate: "1/1/2016",
EndDate: "5/2/2016,"
}
];
and again for clarity, if there were multiple classes the final sorting would end up looking something like this.
Excel (1/1/2016)
Excel (1/2/2016)
Excel (2/3/2016)
Outlook (1/3/2016)
Outlook (2/3/2016)
Word (1/1/2016)
Word (5/5/2016)