Your first JS Sample has a wrong Array Declaration
let myArr = [ 4,2,5,7,3,8,1 ] myArr.sort( ( a, b ) => a-b ) console.log (myArr )
The second example is bad because it doesn't take local circumstances
better:
let string_arr = ['ad', 'ds', 'ar', 'äd' ,'ee'] string_arr.sort( ( a, b ) => a.localeCompare( b ) ); console.log(string_arr);
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Your first JS Sample has a wrong Array Declaration
The second example is bad because it doesn't take local circumstances
better: