例如,给一个特定的字母顺序,"a","o","e","u","y","i",请把'aiye','oeu','ayo','eoyiu','yuo','you','iao'这7个字符串按照给定的字母顺序排序。
我的思路是把那几个给定的6个字母分别等效成0-5的数字,然后把那7个字符串中的字母替换成0-5中的数字,再用sort方法进行排序,代码如下:
<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">