title: Fastest way to sort a python 3.7+ dictionary
body: <p>Now that the <a href="https://mail.python.org/pipermail/python-dev/2017-December/151283.html" rel="noreferrer">insertion order of Python dictionaries is guaranteed</a> starting in Python 3.7 (and <a href="https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6">in CPython 3.6</a>), what is the best/fastest way to sort a dictionary - both by value and by key?</p>
  
  <p>The most obvious way to do it is probably this:</p>
  
  <pre><code>by_key = {k: dct[k] for k in sorted(dct.keys())}
  by_value = {k: dct[k] for k in sorted(dct.keys(), key=dct.__getitem__)}
  </code></pre>
  
  <p>Are there alternative, faster ways to do this?</p>
  
  <p>Note that this question is not a duplicate since previous questions about how to sort a dictionary are out of date (to which the answer was, basically, <em>You can't; use a <code>collections.OrderedDict</code> instead</em>).</p>