I have a table header IP Address, that use AngularJS to sort it. Unfortunately, it doesn't seem to sort IP address.
<th class="text-left">
<a href="" ng-click="sortType = 'device.ip_address'; sortReverse = !sortReverse">
IP Address
</a>
</th>
I want to use something like this
sortFn: function (a, b) {
if (a == b) return 0;
if ( +a.replace(/\./g, '') < +b.replace(/\./g, '')) return - 1;
return 1;
}
How do I use this function above as my sort function in AngularJS?

You should normalize IPs (for example, from
192.168.1.1to192.168.001.001) to properly compare them: