Javascript examples for Array:sort
Sort array of strings with custom sorting for punctuation in first character
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> var nick = ["~x", "@blue", "&demo", "+voice", "%yyy", "1test", "Nick2", "test1"]; console.log(nick); nick.sort(function(a,b){ return a.toLowerCase().replace(/[^\w\s]/gi, '').localeCompare(b.toLowerCase().replace(/[^\w\s]/gi, '')); });/*from w ww . ja va 2s. c o m*/ console.log(nick); </script> </head> <body> </body> </html>