NOTE!
- This parser can be applied to the original plugin.
- The default "ipAdress" parser (IPv4) is included with the original tablesorter; it was moved to the
parser-network.js
file in v2.18.0. - A parser for IPv6 was added in v2.12 and named "ipv6Address":
- Unlike some other custom parsers, this one will auto-detect & check for a valid IPv6 address since the same address can be represented in many different ways. Some examples are shown in the demo table below.
- IPv6 addresses are stored in the cache in their canonical decimal form, without the colons, for faster & easier numerical sorting.
- Extensive unit tests are included with this parser.
- If the parser doesn't auto-detect which column has IPv6 addresses, use the headers sorter option to set it:
$(function(){ $('table').tablesorter({ headers: { 1: { sorter: 'MAC' }, // 2: { sorter: 'ipAddress' }, this parser is auto-detected 3: { sorter: 'ipv6Address' } } }); });
Demo
Name | MAC | IPv4 | IPv6 |
---|---|---|---|
Fred | 12:06:D2:8E:56:BF | 1.2.3.4 | f0f0::1 |
Ginger | 546F.5903.3C9B | 1.1.1.1 | f0::1 |
Mike | 3c-cf-44-cd-6e-d6 | 2.222.33.44 | 1:2:3:4:5::7:8 |
George | ff-68-3d-e8-b4-0d | 255.255.255.255 | ::2:3:4 |
Harry | f566.6dfd.2df2 | 251.2.33.4 | f0f0:f::1 |
Frank | 12:69:13:D8:FA:61 | 251.002.31.4 | :: |
Kristy | A031.5FED.43BC | 2.221.003.4 | 0:0:0:0:0:0:0:0 |
Lily | 82-2D-FF-FA-CD-6C | 251.02.32.4 | f0f0::f:1 |
Maria | 125c395f08f2 | 1.2.3.44 | 1:2:3:4:5:6:1.2.3.4 |
Page Header
<!-- tablesorter --> <link rel="stylesheet" href="../css/theme.blue.css"> <script src="../js/jquery.tablesorter.js"></script> <!-- load ipv6 parser --> <script src="../js/parsers/parser-network.js"></script> <script> $(function() { $('table').tablesorter({ theme: 'blue', widgets: ['zebra'], sortList: [[1, 0]], headers: { 1: { sorter: 'MAC' }, // 2: { sorter: 'ipAddress' }, this parser is auto-detected 3: { sorter: 'ipv6Address' } } }); }); </script>