编辑代码

// 实现 sortVersions 函数试测试用例返回正确的结果
const versions = ['2.01', '1.10', '1.9.10', '1.10.2', '2.0', '1']

function sortVersions(versions) {
  return versions.sort((a, b) => a - b)
}

console.log(sortVersions(versions))
// ["1", "1.9.10", "1.10", "1.10.2", "2.0", "2.01"]