I'm not sure your problem is well-defined right now, so difficult to give you any practical solution. One example of the approach you can take is below:
suppressMessages(library(tidyverse))
y <- tibble(id = 1:4, a1 = 1, d6 = 5, d = 4, a2 = 2, b6 = 3, s1 = 10, r2 = 7)
x <- c("a", "d", "b")
nms <- names(y)
correct_order <-
purrr::map(x, function(prefix) nms[grepl(pattern = paste0("^", prefix), x = nms)]) %>%
purrr::flatten_chr()
pattern <- paste("^", x, "|", collapse = "", sep = "") %>%
stringr::str_replace("\\|$", replacement = "")
res <- y %>% select(id, matches(pattern))
res <- res[correct_order]
res
#> # A tibble: 4 x 5
#> a1 a2 d6 d b6
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 2 5 4 3
#> 2 1 2 5 4 3
#> 3 1 2 5 4 3
#> 4 1 2 5 4 3