I have an array of objects box[], and a div element for each of these objects with class .box. Each object has a numeric property box[].id, which is used to identify the corresponding div element which has the same id attribute. I want to create a function to order the div elements based on other properties of their related objects, I think it would be something like this using JavaScript and jQuery:
// Call my order function based on property1 for example.
sortBox("property1");
function sortBox(property) {
var order;
$(".box").each(function (i) {
// Gets the property on which to sort for each div
order = box[this.id][property];
//////////////////////
//.......????.......//
//////////////////////
});
}
This gets the property for each div to do the sorting but I have no idea what to do after to order the divs based on that property and update the Html. Please help, what is the proper way to do this? Any ideas, examples, suggestions? Thanks in advance.