Reputation: 1746
There is two main aims:
Sort table of data using javascript without libraries such as jquery, so pure javascript.
Sort/group rows together based on class/id (like css).
I thought maybe getElementById could be useful, but don't know enough javascript to investigate properly.
Upvotes: 0
Views: 395
Reputation: 324640
A table's rows can be found in the rows[]
array of said table.
You can create an array containing those rows.
You can then .sort()
the array based on a callback function that looks up certain info, in the form
.sort(function(a,b) { /* return -1 if a comes before b or 1 if b comes before a */ })
If you iterate over the array and appendChild
the rows to the table they are in, the result is a sorted table.
If you have problems with the actual code, please post what you have so far and we can help more specifically ;)
Upvotes: 1