I am writing an App which displays data via datatable. Therefore different forms of text files from users are read in. It is often the case that the order of the columns is mixed up in this files, but the information in it is valid.
After displaying the data I want to do some plausibility routines and therefore I want to say: do XY with the data in "Column A". But if there is the wrong data (because of the wrong order of the columns) the plausibility is useless. Therefore I would like reorder the column names like: Column no. 3 is not 'Column A' but contains the data of 'column B', etc.

What I want to do now is to reorder the column names, not the entire column as done [here](https://stackoverflow.com/questions/65424976/r-shiny-getting-information-from-datatable-with-js-in-shiny).
With the following code I am able to move the whole column, but how do I **only move** the **column names**?

**Edit:** Just to make things clear: no, I don't want to sort the columns while reading in the data. I want to read in the file as it is and just work with the datatable object. This is mainly because I don't know what kind of file i get and what kind of information is in there. So I first of all want to display what's in there and then have a closer look.

```
library(shiny)
library(DT)

ui <- fluidPage(
      DTOutput("table")
      )

server <- function(input, output, session){

    output$table <- renderDT({
    datatable(
      iris,
      rownames = FALSE,
      extensions = "ColReorder",
      options = list(
        colReorder = TRUE
      ),
     colnames = c("S-Length", "S-Width", "P-Length", "P-Width", "Species")
      )
  })
}

shinyApp(ui, server)

```