title: Dask: Sorting truly lazily
body: <p>If I have a dataset with unknown divisions and would like to sort it according to a column and output to Parquet, it seems to me that Dask does at least some of the work twice:</p>
  <pre class="lang-py prettyprint-override"><code>import dask
  import dask.dataframe as dd
  
  def my_identity(x):
      &quot;&quot;&quot;Does nothing, but shows up on the Dask dashboard&quot;&quot;&quot;
      return x
  
  df = dask.datasets.timeseries()
  df = df.map_partitions(my_identity)
  df = df.set_index(['name'])  # &lt;- `my_identity` is calculated here, as well as other tasks
  df.to_parquet('temp.parq') # &lt;- previous tasks seem to be recalculated here
  </code></pre>
  <p>If <code>my_identity</code> was computationally demanding, then recomputing it would be really costly.</p>
  <p>Am I correct in my understanding that Dask does some work twice here? Is there any way to prevent that?</p>