protected void encodeSortableHeaderOnReflow(FacesContext context, DataTable component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        Map<SortMeta, String> headers = getSortableColumnHeaders(context, component);

        if (!headers.isEmpty()) {
            String reflowId = component.getContainerClientId(context) + "_reflowDD";

            writer.startElement("label", null);
            writer.writeAttribute("id", reflowId + "_label", null);
            writer.writeAttribute("for", reflowId, null);
            writer.writeAttribute("class", "ui-reflow-label", null);
            writer.writeText(MessageFactory.getMessage(context, DataTable.SORT_LABEL), null);
            writer.endElement("label");

            writer.startElement("select", null);
            writer.writeAttribute("id", reflowId, null);
            writer.writeAttribute("name", reflowId, null);
            writer.writeAttribute("class", "ui-reflow-dropdown ui-state-default", null);
            writer.writeAttribute("autocomplete", "off", null);

            for (Map.Entry<SortMeta, String> header : headers.entrySet()) {
                for (int sortOrder = 0; sortOrder < 2; sortOrder++) {
                    String sortOrderLabel = (sortOrder == 0)
                                      ? MessageFactory.getMessage(context, DataTable.SORT_ASC)
                                      : MessageFactory.getMessage(context, DataTable.SORT_DESC);

                    writer.startElement("option", null);
                    writer.writeAttribute("value", header.getKey().getColumnKey() + "_" + sortOrder, null);
                    writer.writeAttribute("data-columnkey", header.getKey().getColumnKey(), null);
                    writer.writeAttribute("data-sortorder", sortOrder, null);
                    writer.writeText(header.getValue() + " " + sortOrderLabel, null);
                    writer.endElement("option");
                }
            }

            writer.endElement("select");
        }
    }
Encodes dynamic column. Allows to override default behavior.
primefaces/src/main/java/org/primefaces/component/datatable/DataTableRenderer.java