Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort ip address javascript

arrayOfIps
.sort((a, b) => {
        const num1 = Number(a.split(".").map((num) => (`000${num}`).slice(-3) ).join(""));
        const num2 = Number(b.split(".").map((num) => (`000${num}`).slice(-3) ).join(""));
        return num1-num2;
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #ip #address #javascript
ADD COMMENT
Topic
Name
5+3 =