I have several Objects that contain a reference to DOM elements:
var liObjs = [new Li($el1, price), new Li($el2, price), new Li($el3, price)]
// Li Model
function Li($element, price){
var self = this;
self.price = price;
self.$element = $element;
}
// My DOM Looks like this:
<ul>
<li>Price: $3</li>
<li>Price: $1</li>
<li>Price: $2</li>
</ul>
And and I need them sorted by price based on the objects in liObjs.
I've managed to sort liObjs based on each objects price property but I cannot render them in order for the life of me. Please help.
Note:
The <li>s are already created in DOM but I need to reorder them when the page loads.
$el1a DOM element or the jQuery object containing it.