Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81994

Blanks sort inconsistently in an integer column

$
0
0
In the following code, when sorting on the Age column, note that the blank (Alex's age) appears between 1 and 0 when descending, and between 0 and -1 when ascending.

Shouldn't the sorting be consistent (i.e. always between 0 and 1 or 0 and -1) regardless of ascending or descending.

<script src="@Url.Content("https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js")" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
    $(function() {
        $('#sortableTableDT').dataTable({});
    });
</script>
<table id="sortableTableDT">
	<thead>
		<tr>
			<th>Name</th>
			<th>Age</th>
		</tr>
	</thead>
	<tr>
		<td>Bob</td>
		<td>5</td>
	</tr>
	<tr>
		<td>Alex</td>
		<td></td>
	</tr>
		<tr>
		<td>Frank</td>
		<td>-1</td>
	</tr>
	<tr>
		<td>Zed</td>
		<td>0</td>
	</tr>
	<tr>
		<td>Duncan</td>
		<td>1</td>
	</tr>
</table>

Sort on engine version in this dataTables live example (which uses - instead of <blank>)
http://live.datatables.net/inuziv/2

Viewing all articles
Browse latest Browse all 81994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>