title: Sorting a DataTable using custom function does not work
body: <p>I am working with <a href="https://www.datatables.net/" rel="nofollow">DataTables plug-in</a> in JavaScript.</p>
  
  <p>Usually, if I need to update a cell value, I use the <a href="https://datatables.net/reference/api/cell%28%29.data%28%29" rel="nofollow"><code>cell().data(set)</code></a> method followed by <a href="https://datatables.net/reference/api/draw%28%29" rel="nofollow"><code>.draw()</code></a>.</p>
  
  <p>However, I do not want to use this way because my table contains heavy DOM object. So, when I need to update a cell, I just call some jQuery like <code>$("#cell").attr("myattr", 50)</code> for example, and then I managed to never have to use <code>draw()</code>. This prevents the object to be rebuilt each time, but unfortunately it also means that the DataTable is not aware of these changes (<code>cell().data()</code> returns the unchanged object). </p>
  
  <p>This is a problem when I want my table to be sorted. In fact, the sorting is performed on the data that the datatable known, data which is not changed.</p>
  
  <p>So I thought I could use the <a href="https://datatables.net/reference/option/columns.render" rel="nofollow"><code>columns.render</code></a> option, implementing a function like this:</p>
  
  <pre><code>function(data, type, row, meta) {
      if (type === "sort") {
          return $("#cell").attr("myattr");
      }
      return data;
  }
  </code></pre>
  
  <p>This does not work and I think this is because of the fact that DataTable <a href="https://datatables.net/reference/api/cell%28%29.cache%28%29" rel="nofollow">caches the data</a>. So, as I never update cells data, cache never need to be updated, and sorting is done using this cache, which does not correspond the cell <code>myattr</code> attribute.</p>
  
  <p><strong>I am looking for a workaround which can allow me to sort a DataTable even if cells values are not changed internally but from outside.</strong></p>
  
  <p>Play with <a href="https://jsfiddle.net/L5rbsg98/3/" rel="nofollow">this JSFiddle</a>, clicking the "CHANGE VALUES" button and trying to sort the column, you can see that the values are not correctly ordered.</p>