I have an array which has list of objects.
each value of array looks like :
I want to sort name : elements[ele].options.name
.
this is what I am trying to do ,but not working for me
var sortedElements = elements.sort(function (a, b) {
return a.options.name - b.options.name
});
for (var ele in sortedElements) {
if (sortedElements.hasOwnProperty(ele)) {
if (!sortedElements[ele].options.outOfNetworkFlag) {
if (sortedElements[ele].options.category === "person") {
assignCount++
}
if (sortedElements[ele].options.category === "unknown") {
unassignCount++
}
}
else {
oonCount++;
}
occupancylist += '<a href="#" class="elementLink"><li style="list-style: none" data-elementid="' + sortedElements[ele].options.elementId + '">' + sortedElements[ele].options.icon.options.html + ' ' + sortedElements[ele].options.name + '</li></a>';
}
}
Please suggest.