title: numba: sorting an array in place
body: <p>Numba has the amazing ability to speed up loops with JIT compilation. The key twist, however, is that when using numpy, <a href="http://numba.pydata.org/numba-doc/0.13/arrays.html#array-creation-loop-jitting" rel="noreferrer">one isn't allowed to create any new arrays</a>. Fortunately, most numpy functions include an optional <code>out</code> parameter for writing output to -- except <code>numpy.sort</code>. The most obvious alternative is <code>numpy.ndarray.sort</code>, which IS in place,</p>
  
  <pre class="lang-py prettyprint-override"><code>@njit("void(f8[:])")
  def sort_inplace(arr):
    arr.sort()
  </code></pre>
  
  <p>but this fails to compile,</p>
  
  <pre class="lang-py prettyprint-override"><code>...
  ...
  ...
  /Users/duckworthd/anaconda/lib/python2.7/site-packages/numba/typeinfer.pyc in propagate(self)
      293                 print("propagate".center(80, '-'))
      294             oldtoken = newtoken
  --&gt; 295             self.constrains.propagate(self.context, self.typevars)
      296             newtoken = self.get_state_token()
      297             if config.DEBUG:
  
  /Users/duckworthd/anaconda/lib/python2.7/site-packages/numba/typeinfer.pyc in propagate(self, context, typevars)
      112                 raise
      113             except Exception as e:
  --&gt; 114                 raise TypingError("Internal error:\n%s" % e, constrain.loc)
      115
      116
  
  TypingError: Internal error:
  Attribute 'sort' of array(float64, 1d, A) is not typed
  </code></pre>
  
  <p>Short of re-implementing a sorting algorithm, is there a way to sort a numpy array in a JIT-compiled numba loop?</p>