Thank you so much, changed the function to your suggestion and now the
sort is almost instant:

$("#entries").each(function(prntI,prnt){
        switch($("#myform div.displayOrderDIV input:checked").val()){
                case "createDate":
                        $("div.entry",prnt).sort(function(a,b){
                                var x =
a.childNodes[2].firstChild.innerHTML;
                                var y =
b.childNodes[2].firstChild.innerHTML;
                                return ((x < y) ? -1 : ((x > y) ? 1 :
0));
                        }).appendTo(prnt);
                        break;
                case "updateDate":
                        $("div.entry",prnt).sort(function(a,b){
                                var x =
a.childNodes[4].firstChild.innerHTML;
                                var y =
b.childNodes[4].firstChild.innerHTML;
                                return ((x < y) ? -1 : ((x > y) ? 1 :
0));
                        }).appendTo(prnt);
                        break;
                case "imageName":
                        $("div.entry",prnt).sort(function(a,b){
                                var x =
a.childNodes[6].childNodes[1].innerHTML;
                                var y =
b.childNodes[6].childNodes[1].innerHTML;
                                return ((x < y) ? -1 : ((x > y) ? 1 :
0));
                        }).appendTo(prnt);
                        break;
        }
});

Not quite as human readable or flexible (if the HTML layout changes
this method needs to change) but the speed increase is worth it.

-wade

On Jul 10, 5:37 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> The browser doesn't render anything while you are running a script, only
> when the script stops. That's way alert() makes it work - it stops your
> script and gives the browser a chance to render. You could follow the
> blockUI() call with a 1 millisecond setTimeout call with the rest of your
> code inside the callback function.
>
> But wouldn't you rather have a faster sort? That sort function is going to
> be extremely slow. You may not need blockUI at all if the sort is fast
> enough.
>
> A question related to that: Is the .foo span always the first child element
> of each .entry div? There's one obvious speedup you can make if it is -
> a.firstChild.innerHTML instead of $('span.foo',a).html() - but also a much
> greater speedup by changing the sort algorithm. Let me know on that and I'll
> get back to you with a faster way to sort the entries - or maybe just the
> change above will be good enough.
>
> -Mike
>
> http://groups.google.com/group/jquery-en/browse_frm/thread/e0d6c19955...

Reply via email to