DataTable - Sorting

DataTable has built-in support for ajax sorting.

Ajax Sorting
ModelYearManufacturerColor
a70b9a791966HondaBlack
fc79f9dc1996VolvoWhite
4fe9f0cf1982VolkswagenSilver
4605d1521986BMWBlue
dc34379a1988RenaultRed
6aaa3a1c1978VolkswagenGreen
b98af1051963FordOrange
1a85969b1979JaguarBlack
129feb771982BMWYellow

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>