前一段時間我問了一個問題,修正了它,但現在我遇到了另一個問題。HashMap:使用映射值將字母順序排序
This is jumblesOrdered ArrayList: [act, opst, dgo, art, aprt, fgor]
This is jumbles ArrayList: [atc, otsp, gdo, atr, arpt, grof]
This is dictionaryOrdered ArrayList: [act, act, act, dgo, dgo, opst, opst, opst, opst, opst, opst, art, art, art, aprt, aprt, aprt, fglo, fglo, fgor, gopr, glos]
This is dictionary ArrayList: [act, cat, tac, dog, god, post, pots, stop, spot, tops, opts, rat, tar, art, trap, tarp, part, flog, golf, frog, gorp, slog]
This is jumbleWordHM: {opst=otsp, art=atr, fgor=grof, aprt=arpt, dgo=gdo, act=atc}
This is dictWordHM: {opst=post pots stop spot tops opts, art=rat tar art, glos=slog, gopr=gorp, fgor=frog, aprt=trap tarp part, dgo=dog god, act=act cat tac, fglo=flog golf}Current Output:
電流輸出:
atc act cat tac
otsp post pots stop spot tops opts
gdo dog god
atr rat tar art
arpt trap tarp part
grof frog
所需的輸出:
arpt part tarp trap
atc act cat tac
atr art rat tar
gdo dog god
grof frog
otsp opts post pots spot stop tops
我的用於打印出當前輸出代碼:
for (int i = 0; i < jumblesOrdered.size(); i++) {
String wordAnswer = jumblesOrdered.get(i);
System.out.println(jumbles.get(i) + " " + dictWordHM.get(wordAnswer));
}
每一行的第一個單詞是加密的單詞,後面的單詞是可以從加密的字母組成的字典單詞。
我唯一的問題是,我想組織炒字按字母順序,如:
arpt - dictionary words
atc - dictionary words
atr - dictionary words
etc.....