This is related to but distinct from #839.
Would it be a feature of interest for pivot_wider to put columns in factor level order rather than what appears to be first-seen order?
In the example below, I'd prefer to see column "B" before column "A".
library(tidyr)
d <- data.frame(x = factor(c("A", "B"), levels = c("B", "A")), y = 1:2)
pivot_wider(d, names_from = "x", values_from = "y")
#> # A tibble: 1 × 2
#> A B
#> <int> <int>
#> 1 1 2
Created on 2025-08-28 with reprex v2.1.1