 <p>In Python 2, <code>map()</code> produces a <code>list</code>, which has the method <code>sort()</code>. In Python 3, <code>map()</code> produces a <code>map</code> object, which acts as a lazy generator and does not have the method <code>sort()</code>. If you want to use <code>sort()</code> on it, you'll have to pass that object to <code>list()</code> first:</p> <pre><code>sub = list(sub) sub.sort() </code></pre> <p>Of course, if you're doing that, you might as well just use <code>sorted()</code>, which works on Python 3 <code>map</code> objects as well as <code>list</code> objects:</p> <pre><code>sub = sorted(sub) </code></pre>