I have a array like this
a = [0, "-", "-", "-", "-", "-", -0.2, -0.05, 0.25, 0.47, 0.875].
notice that there are some '-' in this array and only this string appears and the left are numbers.
now I apply sort on this array, just like
a = [0, "-", "-", "-", "-", "-", -0.2, -0.05, 0.25, 0.47, 0.875];
console.log(a.sort((a, b) => (+a || -Infinity) - (+b || -Infinity)));Run Code Online (Sandbox Code Playgroud)
or
a = [0, "-", "-", "-", "-", "-", …Run Code Online (Sandbox Code Playgroud)