Custom sorting functions: IP Address
Opened this issue · 0 comments
emlun007 commented
I have been trying to make a function for sorting ip adresses as tablesort is sorting them alphabetically. I used following sort function:
$('thead th.IP Address').data('myIpArray')
myIpArray='myIpArray'
myIpArray.sort(function(a,b){ // sort IP address.
aa = getIP(a).split(".");
bb = getIP(b).split(".");
for (var i=0, n=Math.max(aa.length, bb.length); i<n; i++) {
if (aa[i] !== bb[i]) return aa[i] - bb[i];
}
return 0;
});
The function still does not sort ip addresses. Anyone got an idea how to make sort work?