Need help with jquery sorting
Posted
by Klerk
on Stack Overflow
See other posts from Stack Overflow
or by Klerk
Published on 2010-05-07T11:26:18Z
Indexed on
2010/05/07
11:28 UTC
Read the original article
Hit count: 150
I have a column within which are multiple 'records' (each a div). Each record has a bunch of fields (each a span whose id is the fieldname).
I want to allow the user to sort all the records based on a field. I also want, the field that has been sorted to be moved to the beginning of the record. So I came up with this. But its really slow for a large sets. Not sure whats the best way to do this. Any ideas?
$(".col1 div").sort(
function (a,b)
{
if($(a).children("."+field).text() > $(b).children("."+field).text())
return -1;
else
return 1;
}).appendTo(".col1");
© Stack Overflow or respective owner