我有一个混合数组,我需要按字母顺序排序,然后按数字排序
[A1, A10, A11, A12, A2, A3, A4, B10, B2, F1, F12, F3]
Run Code Online (Sandbox Code Playgroud)
我如何将其排序为:
[A1, A2, A3, A4, A10, A11, A12, B2, B10, F1, F3, F12]
Run Code Online (Sandbox Code Playgroud)
我试过了
arr.sort(function(a,b) {return a - b});
Run Code Online (Sandbox Code Playgroud)
但是只按字母顺序对其进行排序.可以使用直接JavaScript或jQuery完成吗?
我想用javascript对下拉项目进行排序,任何人都可以告诉我如何做到这一点.
我有一个包含一组链接的div,我的目标是按内容自动对这些链接进行排序,请按照下面的示例进行更好的理解:
之前
<div id="sort-this-div">
<a href="http://something45yer.com">Content3</a>
<a href="http://somethingeyerty.com">Content1</a>
<a href="http://somethingfwegrw.com">Content2</a>
<a href="http://somethingt43rwer.com">Content4</a>
</div>
Run Code Online (Sandbox Code Playgroud)
后
<div id="sort-this-div">
<a href="http://somethingeyerty.com">Content1</a>
<a href="http://somethingfwegrw.com">Content2</a>
<a href="http://something45yer.com">Content3</a>
<a href="http://somethingt43rwer.com">Content4</a>
</div>
Run Code Online (Sandbox Code Playgroud)