Wrap that html in a <div id="hotels"> </div> and try this code
triggered by a button or link.

function reorder(sortby, direction)
{
        Array.prototype.sort.call($("div.hotel"), function(a,b){
                var av = $(a).find("span."+sortby).text();
                var bv = $(b).find("span."+sortby).text();
                return direction=="ascending"? av-bv : bv-av;
        }).appendTo("#hotels");
}

sortby is the class name of any of the spans like distance or rate;
direction is "ascending" (low to high) or "descending". The code
assumes the spans should always be sorted as numeric values.

That code should be plenty fast for a dozen or so entries, but it
would get slow for 100 because it requeries for the span values on
each sort comparison.

Reply via email to