# tablesorter

## IPv4 & IPv6 address parsers

### Flexible client-side table sorting

Back to documentation

NOTE!

- This parser can be applied to the original plugin.
- The default "ipAdress" parser (IPv4) is included with the original tablesorter.
- 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: {
            2: {
              sorter: 'ipv6Address'
            }
          }
        });
      });

# Demo

Name | IPv4 | IPv6
Fred | 1.2.3.4 | f0f0::1
Ginger | 1.1.1.1 | f0::1
Mike | 2.222.33.44 | 1:2:3:4:5::7:8
George | 255.255.255.255 | ::2:3:4
Harry | 251.2.33.4 | f0f0:f::1
Frank | 251.002.31.4 | ::
Kristy | 2.221.003.4 | 0:0:0:0:0:0:0:0
Lily | 251.02.32.4 | f0f0::f:1
Maria | 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-ipv6.js"></script>
    <script>
    $(function() {

      $('table').tablesorter({
        theme: 'blue',
        widgets: ['zebra'],
        sortList: [[1, 0]],
        headers: {
          1: {
            sorter: 'ipv6Address'
          }
        }
      });

    });
    </script>