Skip to content

Custom sorting functions: IP Address #39

Description

@emlun007

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions