0

I need to sort a table of users alphabetically based upon a value in a td element. I can do basic sort fine but I have 3 tbodies per user and I need them all to stick together rather then just a single one of those tbodies being sorted.

This is an example of my table:

<tbody1>
<tr><td>The Value To Base Sort On(username)</td></tr>
<tr></tr>
</tbody>
<tbody2>
<tr><td>some other stuff</td></tr>
<tr></tr>
</tbody>
<tbody1>
<tr><td>other stuff</td></tr>
<tr></tr>
</tbody>

I need these 3 tbodies to remain linked next to each other when the table is sorted, however all 3 should be sorted based upon a value in the first tbody if that makes sense.

3
  • show us something dude. Commented Sep 22, 2011 at 17:28
  • Give us an example of what you have and what you want. Commented Sep 22, 2011 at 17:28
  • Crazy table structure there... You might find this useful: stackoverflow.com/questions/218911/… Commented Sep 23, 2011 at 4:01

1 Answer 1

1

Here is the jQuery plugin you are looking for:

http://james.padolsey.com/javascript/sorting-elements-with-jquery/

$('#someId>li').sortElements( function(a, b){ return $(a).text() > $(b).text() ? 1 : -1; } );
Sign up to request clarification or add additional context in comments.

1 Comment

I couldn't find a solution on that site that seems to be more for single row/sort rather then a group/bundle that I need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.