Q:

What is the logic behind a JavaScript table sorting function?

Once again I need some help. I'm working with a table that contains 3 different types of data (time, alpha and numbers), and it is required that the columns can be sorted (ascending or descending) based on the type of data that each column holds.
So far, the JavaScript that I'm using works well as it was written originally, but there is a lot of HTML in each one of the table cells, and it gets to a point in which the js function chokes when there is 2 values in a particular table cell.
Since I was not the one that wrote the function, I'm having a hard time understanding how it really works(I am also not a js expert).
At this point I've tried many different things and also different plug-ins and nothing has worked the way I need it, so I've decided that the best way for me is to write something from scratch.
I'm not expecting anybody to hold my hand on this one, but I would appreciate if someone with more experience than me helps me understand the logic behind a table sorting function.  
For instance:
In my mind, (and probably my logic is flawed, but that is why I came here to ask) what I have to do is define the data type for each table cell, compare the values of each cell based on that data type, somehow grab the entire row for each cell and rearrange the table rows based on the desired order.
I'm ok with jQuery or plain JavaScript.  
Thanks in advance for any help that you want to offer.

A:

It sounds to me the JavaScript is confused about what value to use to sort by in each column. If the JavaScript being used is uncompressed I would make a change to it to use a value within the cell tag that allows you to specify the value you want to sort by:
<td data-value="15"><strong>15</strong> - Text in here, etc.</td>

If you are using HTML5 you can use data-value. You can substitute -value for what ever you wanted to call the data field. If you aren't using HTML5 a lot of JavaScript will use the rel HTML value. In this case:
<td rel="15"><strong>15</strong> - Text in here, etc.</td>

I hope this is helpful. If anything needs clarification or you need more help let me know.

