Sort TableView by certain column Javafx
<p>I'm trying to sort a <code>TableView table</code> by a certain column. When I display the table, it's shown but from what I'm finding on here and other sites it's just confusing me more and more.</p>

<p>here is the tableview code</p>

<pre><code>public TableView&lt;Animal&gt; animalLostLocation(ArrayList&lt;Animal&gt; list)
    {

        TableColumn&lt;Animal, String&gt; atypeColumn = new TableColumn&lt;&gt;("Animal Type");
        atypeColumn.setMinWidth(200);
        atypeColumn.setSortable(false);
        atypeColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("aType"));

        TableColumn&lt;Animal, String&gt; descriptionColumn = new TableColumn&lt;&gt;("Description");
        descriptionColumn.setMinWidth(200);
        descriptionColumn.setSortable(false);
        descriptionColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("description"));

        TableColumn&lt;Animal, String&gt; breedColumn = new TableColumn&lt;&gt;("Breed");
        breedColumn.setMinWidth(80);
        breedColumn.setSortable(false);
        breedColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("breed"));

        TableColumn&lt;Animal, String&gt; nameColumn = new TableColumn&lt;&gt;("Name");
        nameColumn.setMinWidth(200);
        nameColumn.setSortable(false);
        nameColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("name"));

        TableColumn&lt;Animal, Catergory&gt; catColumn = new TableColumn&lt;&gt;("Category");
        catColumn.setMinWidth(200);
        breedColumn.setSortable(false);
        catColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("category"));

        TableColumn&lt;Animal, Integer &gt; ageColumn = new TableColumn&lt;&gt;("Age");
        ageColumn.setMinWidth(50);
        ageColumn.setSortable(false);
        ageColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("age"));

        TableColumn&lt;Animal, Integer &gt; idColumn = new TableColumn&lt;&gt;("ID");
        idColumn.setMinWidth(50);
        idColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("ID"));

        TableColumn&lt;Animal, Boolean &gt; genColumn = new TableColumn&lt;&gt;("Male");
        genColumn.setMinWidth(50);
        genColumn.setSortable(false);
        genColumn.setCellValueFactory(new PropertyValueFactory&lt;&gt;("gender"));

        table = new TableView&lt;Animal&gt;();

        table.setItems(getAnimal(list));

        table.getColumns().addAll(genColumn, idColumn, nameColumn, atypeColumn, ageColumn, breedColumn, descriptionColumn, catColumn);
        return table;
    }
</code></pre>

<p>I want to sort the table by gender initially.</p>

<p>As far as I know I have to create a <code>SortedList</code>/<code>FilteredList</code> but the tutorial I found online is just confusing me even more. </p>

<p>Do I have to use <code>SortedList</code>/<code>FilteredList</code> or are there better alternatives? </p>

<p>Here's one of the links I found <a href="http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/" rel="noreferrer">http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/</a></p>

<p>Can anyone dumb it down for me please?</p>