简体   繁体   中英

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

I need to sort a collection of 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM