title: What data structure (java) should I use to store a set of strings and their standard form?
body: <p>I'm trying to create a dictionary of words that will store a word and its "canonical" form, i.e. an alphabetized version of all the characters in the String. I then have to access all words that could come from one canonical form. For example, if I have the words "sport" and "ports", my canon form is "oprst", and I want to be able to retrieve both "sport" and "ports" from just the canonical form.</p>
  
  <p>I have the dictionary in the form of an ArrayList, and I want to be able to access all words from the dictionary that match to one canonical form.</p>
  
  <p>I've tried using a HashMap but I realized that because I need to be able to access the original words from the canonical form that doesn't work. I've attempted to use an ArrayList, but can't think of how to do it so that I can match a String to its canonical form. Maybe by creating one ArrayList of the normal words, then another with the canonical form for each word at a matching index, but I feel like there must be a more efficient way.</p>
  
  <p>Map attempt:</p>
  
  <pre><code>Map end = new HashMap&lt;String,String&gt;(words.size());
  for(int i=0; i &lt; words.size(); i++){
              end.put(input,canonize(input));
          }
          return end;
  </code></pre>
  
  <p>ArrayList attempt (the idea was that I'd split the array at the comma):</p>
  
  <pre><code>for(int i=0; i &lt; words.size(); i++){
              String input = words.get(i);
              words.set(i,input + "," + canonize(input));
          }
          return words;
  </code></pre>
  
  <p>The issue with both of these methods is that I cannot find a way to return all of the words that match to one canonical form. I can figure out whether a word is in the dictionary, but I want to be able to basically take a jumble of letters, "canonize" them, and then find all the words using those letters from the canon form.</p>
  
  <p>I've looked around and found ternary search trees, but I don't really understand how to use them well enough as I'm still learning Java.</p>
  
  <p>EDIT: Solved, I just didn't think of Map>. Thank you.</p>