【发布时间】:2013-01-06 19:16:55
【问题描述】:
我正在尝试对带有值和文本的选择选项进行排序,如下所示。 文本可以有特殊字符并且需要排序。 但是我发现,一些特殊字符出现在字母之后。 我想要所有特殊字符,然后是字母。
c = [["#test","#test"], ["?test", "?test"], ["test", "test"], ["TEst", "TEst"], ["]test", "]test"]]
>>> c.sort()
[["#test", "#test"], ["?test", "?test"], ["TEst", "TEst"], ["]test", "]test"], ["test", "test"]]
问题似乎是“测试”。
另一个简单的例子:
cool = ['#new','?new','[new',']new','NEw','&new','cool','ind']
["#new", "?new", "[new", "]new", "NEw", "&new", "cool", "ind"]
cool.sort()
["#new", "&new", "?new", "NEw", "[new", "]new", "cool", "ind"]
【问题讨论】:
标签: javascript arrays selection