How to sort arrays containing special characters in js?

description

has an array, which can contain special characters such as -, * , and others are strings and numbers. How to sort this array?

var arr=[5,1,"aa",44,"-","cc","-"]

how do I sort the above array?

sort result:

[1 code >

Mar.02,2021

what do you need to line up


Array.sort () , the collation can be written by yourself
eg:

  

sort out the collation, and then write the corresponding function to ok

Menu