版本号大小比较,如 1.3.5, 1.10.1 ,直接在sort上扩展一下就好了:
data.sort(function (a, b) {
var sources = a.sdk_version.split('.')
var dests = b.sdk_version.split(',')
var minL = Math.min(sources.length, dests.length)
var r = null
for (let i = 0; i < minL; i++) {
if (sources[i] < dests[i]) {
r = 1
break
} else if (sources[i] > dests[i]) {
r = -1
break
} else if (i === minL && sources[i] === dests[i]) {
r = 0
}
}
return r
})