DataTable - Sorting

DataTable has built-in support for ajax sorting.

Ajax Sorting
ModelYearManufacturerColor
0183875c1973FordMaroon
0e1962781986AudiMaroon
57f5eee21962VolvoGreen
2ec7bfaf2008OpelBlack
8d20c9241976FerrariGreen
98f6605a2009AudiBlue
5fec45e41990RenaultBlack
5bccafdc2007ChryslerBlue
26c598e21998MercedesMaroon

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>