Home >Web Front-end >JS Tutorial >js code to sort strings in specific alphabetical order_javascript skills
For example, given a specific alphabetical order, "a", "o", "e", "u", "y", "i", please put 'aiye', 'oeu', 'ayo', 'eoyiu' ,'yuo','you','iao', the seven strings are sorted in the given alphabetical order.
My idea is to equate the given 6 letters into numbers from 0-5, and then replace the letters in the 7 strings with numbers from 0-5, and then Use the sort method to sort, the code is as follows:
</pre> ;<pre code_snippet_id="173179" snippet_file_name="blog_20140127_1_4210131" name="code" class="html"><span class="source-code" style="font-family:Consolas,'Lucida Console', monospace; white-space:pre-wrap"><span style="font-family:Consolas,'Lucida Console',monospace; white-space:pre-wrap"></span></span> ;<pre code_snippet_id="173179" snippet_file_name="blog_20140127_1_4210131">