This plots as expected:
ggplot(mpg, aes(x = class, order = drv, fill = drv)) +
geom_bar(position = position_dodge(preserve = "single")) +
theme_bw()
This one is almost correct, but it seems the widths of the bars take into account the number of groups (5) rather then the number of distinct order values (3):
ggplot(mutate(mpg, drvXyear = paste0(drv, "|", year)),
aes(x = class, order = drv, fill = drvXyear)) +
geom_bar(position = position_dodge(preserve = "single")) +
theme_bw()
ggplot2 v4.0.1