版本號(hào)大小比較,如?1.3.5, 1.10.1?望忆,直接在sort上擴(kuò)展一下就好了:
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
})