Re: [jQuery] Reorder list numerically based on attribute?

2009-11-24 Thread Alexandru Adrian Dinulescu
Sorry to highjack this, but Karl could you somehow describe exactly what that function does, my js is pretty rusty but i would like to understand how it works. Thanks --- Alexandru Dinulescu Web Developer (X)HTML/CSS Specialist Expert Guarantee Certified Developer XHTML:

[jQuery] Reorder list numerically based on attribute?

2009-11-23 Thread welshy1984
I am wondering if it is possible to reorder a unordered list based on the list items 'rel' attribute? i have a list of items that change dynamically (its linked in with google maps, the 'rel' attribute of the list item is updated with the new distance from the google map marker icon when the

Re: [jQuery] Reorder list numerically based on attribute?

2009-11-23 Thread Karl Swedberg
Something like this might work... var items = $('li').get(); items.sort(function(a, b) { var relA = +$(a).attr('rel'); var relB = +$(b).attr('rel'); if (relA relB) { return 1; } if (relA relB) { return -1; } return 0; }); for (var i=0; i items.length; i++) {