I’m doing sorting of a list of elements, using:
jQuery.fn.sort = function() {
return this.pushStack( [].sort.apply( this, arguments ), []);
};
$("ol li").sort("sortFunction").appendTo("ol");
The problem is in the sortFunction.
function sortFunction($a, $b) {
...
}
Basically, what I want is to treat both $a and $b as jQuery objects, so I can manipulate them.
e.g, inside the sortFunction do
$a.find("div#3 li").html();
This doesn’t work since $a and $b are native javascript objects.
Any help?
They are native DOM elements. You can call the jQuery function on one to wrap it, so that the jQuery functions are available: