문제

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>
도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top