fix tabs
This commit is contained in:
@@ -32,26 +32,34 @@ function portSort (a, b) {
|
|||||||
// convert all to strings and trim()
|
// convert all to strings and trim()
|
||||||
x = a.toString().replace(sre, '') || '',
|
x = a.toString().replace(sre, '') || '',
|
||||||
y = b.toString().replace(sre, '') || '';
|
y = b.toString().replace(sre, '') || '';
|
||||||
|
|
||||||
// hack for foundry "10GigabitEthernet" -> cisco-like "TenGigabitEthernet"
|
// hack for foundry "10GigabitEthernet" -> cisco-like "TenGigabitEthernet"
|
||||||
x = x.replace(/^10GigabitEthernet/, 'GigabitEthernet');
|
x = x.replace(/^10GigabitEthernet/, 'GigabitEthernet');
|
||||||
y = y.replace(/^10GigabitEthernet/, 'GigabitEthernet');
|
y = y.replace(/^10GigabitEthernet/, 'GigabitEthernet');
|
||||||
|
|
||||||
// chunk/tokenize
|
// chunk/tokenize
|
||||||
var xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
var xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
|
||||||
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0');
|
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0');
|
||||||
|
|
||||||
for (var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
for (var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
|
||||||
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
||||||
var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
||||||
var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||||
|
|
||||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) return (isNaN(oFxNcL)) ? 1 : -1;
|
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
|
||||||
|
return (isNaN(oFxNcL)) ? 1 : -1;
|
||||||
|
}
|
||||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||||
else if (typeof oFxNcL !== typeof oFyNcL) {
|
else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||||
oFxNcL += '';
|
oFxNcL += '';
|
||||||
oFyNcL += '';
|
oFyNcL += '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oFxNcL < oFyNcL) return -1;
|
if (oFxNcL < oFyNcL) return -1;
|
||||||
if (oFxNcL > oFyNcL) return 1;
|
if (oFxNcL > oFyNcL) return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user