Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom sorting functions: IP Address #39

Open
emlun007 opened this issue Nov 14, 2017 · 0 comments
Open

Custom sorting functions: IP Address #39

emlun007 opened this issue Nov 14, 2017 · 0 comments

Comments

@emlun007
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant