例如,給一個特定的字母順序,"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',monspace; 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">