最终效果:

zTree、jsTree排序和简单的js数字字符串混合排序方法

 

实现方法:

// 使用js中Array类型的原生方法sort与String类型的原生方法localeCompare实现
    afterSortDataList = beforeSortDataList.sort(function (a, b) {
        return a.name.localeCompare(b.name, 'zh-CN', { numeric: true });
    })

 

关于localeCompare方法的详细使用方式,可以前往下面的地址查阅

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-07-12
  • 2021-04-26
  • 2022-12-23
  • 2021-06-07
猜你喜欢
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
相关资源
相似解决方案