title: Halide - sort buffer/function in one dimension
body: <p>I am currently using Halide with the use of a generator and ahead of time compilation.</p>
  <p>Somewhere in the pipeline I have a 3D buffer with limited extent (typically 3-6 values) in one of the dimensions.
  I would like to sort the values in that dimension.
  When I skip the processing at the beginning of the pipe line,
  it looks somewhat like this:</p>
  <pre><code>Input &lt;  Buffer&lt;uint16_t&gt;&gt; input  { &quot;input&quot; , 2}; // Dimensions: (y, x)
  Input &lt;  uint8_t&gt;        &gt; sizeZ  { &quot;sizeZ&quot;    }; // Size in Z-dimension
  Output&lt;  Buffer&lt;uint16_t&gt;&gt; output { &quot;output&quot;, 3}; // Dimensions: (z, y, x)
  
  Var x,y,z;
  
  Func input3D(z,y,x) = input(y,z+x*sizeZ);
  
  output = 'sort input3D on Z dimension'.
  </code></pre>
  <p>I would be most helped if some sorting functionality is already available in Halide (is that so?).
  An alternative would be to call an external C implementation to sort all values in that dimension and assign them to the output buffer.
  That would be something like:</p>
  <pre><code>output(:, y, x) = external_sort(input(:, y, x))
  </code></pre>
  <p>In which I used the Python notation to express all elements in Z dimension.
  Is something like this possible in Halide?</p>