I am trying to implement an algorithm that finds all the anagrams (permutations) of a string of letters.

My thinking: Do it by alphabetical order.

So abc, acb, bac, bca, cab, cba

1. Sort strings by alphabetical order.

2. Swap other 2 letters in each string in the case of n = 3.