title: javafx: sort TableView by default
body: <p>I'm developing a small game that has a highscore list displayed by a javafx <code>TableView</code>. I've created a subclass <code>HighscoreTableView extends TableView</code> which is a <code>TableView</code> node that automatically creates the <code>TableColumns</code> I need and fills them with data on construction.</p>
  
  <p>I want that table to be sorted by a default column on initialisation. I've added the following code lines:</p>
  
  <pre><code>duration.setSortType(TableColumn.SortType.DESCENDING);
  this.getSortOrder().add(duration);
  duration.setSortable(true);
  this.sort();
  </code></pre>
  
  <p>where duration is the <code>TableColumn</code> that should define the sorting. Of course, it's added to the <code>TableView</code>. But when I create a new instance of that <code>HighscoreTableView</code>, it remains unsorted by default, until the user clicks on one of the column headers. This is unexpected, since <a href="https://stackoverflow.com/questions/36240142/sort-tableview-by-certain-column-javafx">this question</a>, <a href="https://stackoverflow.com/questions/11096353/javafx-re-sorting-a-column-in-a-tableview">this question</a> and <a href="https://stackoverflow.com/questions/19250951/javafx-tableview-arrow-for-a-column-sorted-by-default">this question</a> say it should work that way. Any ideas?</p>
  
  <p><strong>Further information for reproduction:</strong>
  The <code>HighscoreTableView</code> class is used by a <code>HighscoreStage extends Stage</code> class, which contains a <code>TabPane</code> with four Tabs. Each Tab contains a <code>HighscoreTableView</code> with different data taken from a static <code>Data</code> object. The data model is a class <code>HighscoreEntry</code>, an <code>ObservableList</code> of them gets added to the <code>HighscoreTableView</code>s. My full code is available <a href="https://gist.github.com/LukeLR/a2806cb26f7c7bef3a20e0eec14e69c6" rel="nofollow noreferrer">here</a>.</p>