Use sprintf("var_%02d", n) instead of paste0("var_", n) to name the columns, to ensure that leading zeroes are added to the column names (e.g. var_01, var_02, etc). Ordering should be easier after that (if needed at all). Change the 2 in %02d to the appropriate number of digits the numbering should have.