Author: jebnor
Description:
Colums in the IP/CIDR format to not sort properly in class="wikitable sortable" tables.
IPs sort correctly, (apparently using numeric sort, which is nice.)
{| class="wikitable sortable" ! A !! IP |- | errata-prod || 25.71.30.0 |- | errata-test || 25.71.31.0 |- | Satellite || 25.71.32.0 |- | foobar || 25.23.33.0 |- | AD3 || 25.71.33.0 |- | AD3 FOO || 25.71.34.0 |- | zfs || 192.168.151.0 |}
Upon sorting by IP, we get a table like this:
A | IP |
---|---|
foobar | 25.23.33.0 |
errata-prod | 25.71.30.0 |
errata-test | 25.71.31.0 |
Satellite | 25.71.32.0 |
AD3 | 25.71.33.0 |
AD3 FOO | 25.71.34.0 |
zfs | 192.168.151.0 |
However when we add the CIDR mask to the IPs, the table does not sort correctly.
{| class="wikitable sortable" ! A !! IP |- | errata-prod || 25.71.30.0/24 |- | errata-test || 25.71.31.0/24 |- | Satellite || 25.71.32.0/24 |- | foobar || 25.23.33.0/24 |- | AD3 || 25.71.33.0/24 |- | AD3 FOO || 25.71.34.0/24 |- | zfs || 192.168.151.0/24 |}
Sorting by IP gives
A | IP |
---|---|
errata-prod | 25.71.30.0/24 |
errata-test | 25.71.31.0/24 |
Satellite | 25.71.32.0/24 |
foobar | 25.23.33.0/24 |
AD3 | 25.71.33.0/24 |
AD3 FOO | 25.71.34.0/24 |
zfs | 192.168.151.0/24 |
Which is incorrect, 'foobar' is not where is should be. It appears to be sorted by the third decimal octet which is confirmed by changing the foobar value to '25.23.47.0/24'
Which gives the 'sorted' table
A | IP |
---|---|
errata-prod | 25.71.30.0/24 |
errata-test | 25.71.31.0/24 |
Satellite | 25.71.32.0/24 |
AD3 | 25.71.33.0/24 |
AD3 FOO | 25.71.34.0/24 |
foobar | 25.23.47.0/24 |
zfs | 192.168.151.0/24 |
Changing the CIDR mask doesn't change the outcome
A | IP |
---|---|
errata-prod | 25.71.30.0/16 |
errata-test | 25.71.31.0/16 |
Satellite | 25.71.32.0/16 |
AD3 | 25.71.33.0/16 |
AD3 FOO | 25.71.34.0/24 |
foobar | 25.23.47.0/16 |
zfs | 192.168.151.0/24 |
EXPECTED OUTCOME:
Table Sorted by IP/CIDR should output the rows in the same order as IP alone.
A | IP |
---|---|
foobar | 25.23.47.0/16 |
errata-prod | 25.71.30.0/16 |
errata-test | 25.71.31.0/16 |
Satellite | 25.71.32.0/16 |
AD3 | 25.71.33.0/16 |
AD3 FOO | 25.71.34.0/24 |
zfs | 192.168.151.0/24 |