Question

I found a great answer for this question but I still have problems. If you put in the second column values like 1.5 or 1, the sorting will be wrong. How can this be fixed? Thanks a lot! I edited the JSFiddle: http://jsfiddle.net/CYubV/7/

<table id=table>
    <thead><tr><th>Normal</th><th>Nullable</th></tr></thead>
    <tbody>
        <tr>
           <td>15</td>
           <td>1</td>
        </tr>
        <tr>
           <td>4</td>
           <td>1.5</td>
         </tr>
    </tbody>
</table>
Was it helpful?

Solution

I think you need to use ParseFloat to handle the comparison between the whole integers and the decimals. Fiddle Here

var ia = parseFloat(a);
var ib = parseFloat(b);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top