("Forward-port" of r46506)

Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.

Remaining open issues:
 * test_extcall is an output test, messy to make robust
 * tarfile.py has a potential bug here, but I'm not familiar
   enough with this code.  Filed in as SF bug #1496501.
 * urllib2.HTTPPasswordMgr() returns a random result if there is more
   than one matching root path.  I'm asking python-dev for
   clarification...
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 971ec6c..b87df7c 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -1056,12 +1056,13 @@
 
         >>> tests = DocTestFinder().find(_TestClass)
         >>> runner = DocTestRunner(verbose=False)
+        >>> tests.sort(key = lambda test: test.name)
         >>> for test in tests:
-        ...     print runner.run(test)
-        (0, 2)
-        (0, 1)
-        (0, 2)
-        (0, 2)
+        ...     print test.name, '->', runner.run(test)
+        _TestClass -> (0, 2)
+        _TestClass.__init__ -> (0, 2)
+        _TestClass.get -> (0, 2)
+        _TestClass.square -> (0, 1)
 
     The `summarize` method prints a summary of all the test cases that
     have been run by the runner, and returns an aggregated `(f, t)`