Fix IP address sorting when there are empty entries in the table

When a table contains empty values, sorting by IP addresses using the `ip-address.js` sorting plugin
caused erratic sorting behaviour. The empty lines are not sorted correctly and remain scattered about
the rest of the rows.

This seems to be due to a type issue: The ip-address sorting plugin has a guard-clause if-statement
that checks if the value that is to be sorted is false-y. In that case, the integer `0` is returned.
The function seems to usually normalise ip addresses to a lexicographically sortable format, and
values like `"86b4b93fbbf0418144b55bc45057b720"` and `"173040030054"` are returned.

The resulting comparison between strings and integers seems to cause misplaced empty rows and all-over
weird sorting behaviour.

This commit changes the value returned by the guard-clause to the string value `"000000000000"`, which
is simliar to the normalized IPv4 format already used by the plugin.
pull/531/head
Paik Paustian 3 years ago
parent b820aaeee5
commit 5470f7a42d
No known key found for this signature in database
GPG Key ID: E1BC2166049E8755

@ -25,7 +25,7 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
var x, xa;
if (!a) {
return 0
return '000000000000';
}
a = a.replace(/<[\s\S]*?>/g, "");

Loading…
Cancel
Save