I got an array of objects like this one:
var SkillBuddys = [
{
Property1: "1",
Property2: "Test",
Property3: "Data",
Property4: [{},{},{}],
}, {
Property1: "2",
Property2: "Test2",
Property3: "Data2"
}, {
Property1: "3",
Property2: "Test3",
Property3: "Data3",
Property4: [{},{}],
}, {
Property1: "4",
Property2: "Test4",
Property3: "Data4"
}, {
Property1: "5",
Property2: "Test5",
Property3: "Data5",
Property4: [{}],
}
];
I want to sort it with javaScript on Property 4, so if the object has the property 4 and contains an array. Like this:
var SkillBuddys = [
{
Property1: "1",
Property2: "Test",
Property3: "Data",
Property4: [{},{},{}],
}, {
Property1: "3",
Property2: "Test3",
Property3: "Data3",
Property4: [{},{}],
}, {
Property1: "5",
Property2: "Test5",
Property3: "Data5",
Property4: [{}],
}, {
Property1: "2",
Property2: "Test2",
Property3: "Data2"
}, {
Property1: "4",
Property2: "Test4",
Property3: "Data4"
}
];
If Property 4 does not exists it returns "Undefined". How can i sort this with Array.Sort?