ipSortNatural() {
      const ipNaturalSort = _.get(this.sort, 'ipNaturalSort', false);
      const ipListSortedKeys = _.get(this.infra, 'internet.ipList.sortedKeys', []);

      return (ip) => {
        // only if natural sort is activated ...
        if (!ipNaturalSort) {
          return _.indexOf(ipListSortedKeys, ip.id);
        }

        const ipRegex = new RegExp(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
        if (ip && ipRegex.test(ip.ip)) { // IPv4 ...
          const values = ipRegex.exec(ip.ip);
          let score = 0;
          score += parseInt(values[1], 10) * 1000000000;
          score += parseInt(values[2], 10) * 1000000;
          score += parseInt(values[3], 10) * 1000;
          score += parseInt(values[4], 10);
          return score;
        }
        return ip.ip;
      };
    }
/**
         * Sort IPs in their natural order
         */
Sort IPs in their natural order
Sort IPs in their natural order
ipSortNatural() {
      const ipNaturalSort = _.get(this.sort, 'ipNaturalSort', false);
      const ipListSortedKeys = _.get(this.infra, 'internet.ipList.sortedKeys', []);
      return (ip) => {
        if (!ipNaturalSort) {
          return _.indexOf(ipListSortedKeys, ip.id);
        }
        const ipRegex = new RegExp(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
        if (ip && ipRegex.test(ip.ip)) { 
          const values = ipRegex.exec(ip.ip);
          let score = 0;
          score += parseInt(values[1], 10) * 1000000000;
          score += parseInt(values[2], 10) * 1000000;
          score += parseInt(values[3], 10) * 1000;
          score += parseInt(values[4], 10);
          return score;
        }
        return ip.ip;
      };
    }
ipSortNatural ( ) { const ipNaturalSort = _ . get ( this . sort , 'ipNaturalSort' , false ) ; const ipListSortedKeys = _ . get ( this . infra , 'internet.ipList.sortedKeys' , [ ] ) ; return ( ip ) => { if ( ! ipNaturalSort ) { return _ . indexOf ( ipListSortedKeys , ip . id ) ; } const ipRegex = new RegExp ( / (\d+)\.(\d+)\.(\d+)\.(\d+) / ) ; if ( ip && ipRegex . test ( ip . ip ) ) { const values = ipRegex . exec ( ip . ip ) ; let score = 0 ; score += parseInt ( values [ 1 ] , 10 ) * 1000000000 ; score += parseInt ( values [ 2 ] , 10 ) * 1000000 ; score += parseInt ( values [ 3 ] , 10 ) * 1000 ; score += parseInt ( values [ 4 ] , 10 ) ; return score ; } return ip . ip ; } ; }
Sort IPs in their natural order
Sort IPs in their natural order
// only if natural sort is activated ... // IPv4 ...