title: Algorithms for computing the distance between two strings
body: <p>Is there any string distance algorithm that doesnt not take into account the order of the words?</p>
  
  <p>The following algorithms do not give the desired results(in that example the desired result should be 1):</p>
  
  <pre><code>import jaro
  jaro.jaro_winkler_metric(u'Michael Jordan',u'Jordan Michael')
  &gt;&gt;&gt;0.47
  
  import Levenshtein
  Levenshtein.ratio('Michael Jordan', 'Jordan Michael')
  &gt;&gt;&gt;0.5
  
  from difflib import SequenceMatcher
  SequenceMatcher(None, 'Michael Jordan', 'Jordan Michael').ratio()
  &gt;&gt;&gt;0.5
  </code></pre>
  
  <p>One way to making that is to have the string in alphabetical order and later use on of the above algorithms:</p>
  
  <pre><code>''.join(sorted('Michael Jordan'))
  &gt;&gt;&gt;' JMaacdehilnor'
  
  ''.join(sorted('Jordan Michael'))
  &gt;&gt;&gt;' JMaacdehilnor'
  </code></pre>
  
  <p>But here the information of the name and surname is lost and will not have 'stable' results. </p>
  
  <p>I have created a function ,using <code>permutations</code> from <code>itertools</code>, that takes all the possible compilations of the words and compare the strings and output the max value. The results are satisfactory but the whole procedure is really slow when I have to compare millions of names. </p>
  
  <p>Something else that can be done is to sort the words such as:</p>
  
  <pre><code>' '.join(sorted('Michael Jordan'.split()))
  &gt;&gt;&gt;'Jordan Michael'
  ' '.join(sorted('Jordan Michael'.split()))
  &gt;&gt;&gt;'Jordan Michael'
  </code></pre>
  
  <p>Seems quite nice way and easy way to decrease the computations but we loose some sensitive cases. example:</p>
  
  <pre><code>name1 = ' '.join(sorted('Bizen Dim'.split()))
  &gt;&gt;&gt;'Bizen Dim'
  name2 = ' '.join(sorted('Dim Mpizen'.split()))
  &gt;&gt;&gt;'Dim Mpizen'
  
  SequenceMatcher(None, name1, name2).ratio()
  &gt;&gt;&gt;  0.55
  </code></pre>
  
  <p>These two names are the same as there are cases where people 'translating' their names from 'b' to 'mp' (I am one of them). Using this way we are loosing this 'match'. </p>
  
  <p>Is there any string distance algorithm that compares the words and do not take into consideration the order of the words? Or is there a recommendation how to implement efficiently the desired function?</p>