DataTable - Sorting

DataTable has built-in support for ajax sorting.

Ajax Sorting
ModelYearManufacturerColor
4f0982441969BMWBrown
0536e7901974BMWOrange
c58a822c2001VolvoGreen
f1698dcd2002OpelBlue
189a369e2004FerrariBrown
2cf739a41992VolvoYellow
bd5c195e1961FordGreen
99b467e52004VolkswagenRed
c03aae7f2000AudiRed

Source

<h:form>

    <p:dataTable id="dataTable" var="car" value="#{tableBean.carsSmall}">
        <f:facet name="header">
            Ajax Sorting
        </f:facet>

        <p:column sortBy="model" headerText="Model">
            <h:outputText value="#{car.model}" />
        </p:column>

        <p:column sortBy="year" headerText="Year">
            <h:outputText value="#{car.year}" />
        </p:column>

        <p:column sortBy="manufacturer" headerText="Manufacturer">
            <h:outputText value="#{car.manufacturer}" />
        </p:column>

        <p:column sortBy="color" headerText="Color">
            <h:outputText value="#{car.color}" />
        </p:column>
    </p:dataTable>

</h:form>