1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| function versionCompare(versionA, versionB) {
var versionAList = versionA.split('.');
var versionBList = versionB.split('.');
var maxLen = Math.max( versionAList.length, versionBList.length );
var result, a, b;
for (var i = 0; i < maxLen; i++) {
a = ~~versionAList[i];
b = ~~versionBList[i];
if(a > b) result = 1;
else if (a < b) result = -1;
else result = 0;
if (result !== 0) return result;
}
return result;
}
|