排序的JavaScript字符串数组包含数字 [英] Sort JavaScript String Array containing numbers
本文介绍了排序的JavaScript字符串数组包含数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在JavaScript中的数组包含以下内容:
I have an array in JavaScript that contains the following:
- [值1,值5。 值10,11值];
我怎么会去选这个阵列,因此它不会出现如下:
How would I go about sorting this array so that it does not appear as follows:
- [值1,值10。 值11,值5];
但为:
- [值1,值5。 值10,11值];
任何帮助将是巨大的。
推荐答案
如果你是热衷于自己写的话,你可以分析与常规的前pression的项目,比较的第二个组成部分。这些将匹配类似
If you are enthusiastic about writing it yourself, you can just parse the items with an regular expression and compare the second part. Those will match something like
价值\\ S [1-9] [0-9] *?
"Value\s[1-9][0-9]*"
这篇关于排序的JavaScript字符串数组包含数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文