alphanumeric sorting in java script

青春壹個敷衍的年華 提交于 2020-01-11 09:17:27

问题


i am having the field which has data in this way . A_0121-X-1
A_0121-X-10
A_0121-X-11
A_0121-X-2
A_0121-X-3 A_0121-Z-1 A_0121-Z-11 A_0121-Z-12 A_0121-Z-13 A_0121-Z-2 A_0121-Z-3 S0 How to sort numerically like this

A_0121-X-1
A_0121-X-2
A_0121-X-3 A_0121-X-10
A_0121-X-11 A_0121-Z-1
A_0121-Z-2 A_0121-Z-3 A_0121-Z-11 A_0121-Z-12 A_0121-Z-13

Thanks in advance


回答1:


i think you mean to natural sort in js

look on Brian Huisman solution

https://web.archive.org/web/20130929122019/http://my.opera.com/GreyWyvern/blog/show.dml/1671288



来源:https://stackoverflow.com/questions/4321829/alphanumeric-sorting-in-java-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!