开发者

Sorting a string with special characters like this N/S,N/A

开发者 https://www.devze.com 2023-04-02 05:10 出处:网络
I need to sort a collection of开发者_Go百科 strings, some of which contain special characters, in JavaScript.

I need to sort a collection of开发者_Go百科 strings, some of which contain special characters, in JavaScript.

Here is some examples to sort

N/S
N/A 
dd/mm/yy (Date format)

like in which these Strings are containing a special character '/'.

For now I'm using sort method on array which is not fixing the issue as expected.


The examples you provide aren't helpful as you don't provide the sorting rules that go with them.

The sort method accepts (as an argument) a function which describes the sorting rules. Express your rules in that function. There are some examples of how to write this function in the documentation for sort on MDN

0

精彩评论

暂无评论...
验证码 换一张
取 消