You want to turn your categorical column you're faceting by, "location", into a factor, like in the below code. You may be better adding a mutate() step first to turn location into a factor rather than doing it within the facet function, however.
library(tidyverse)
# original order
palmerpenguins::penguins %>%
ggplot(aes(x = body_mass_g, color = island)) +
geom_density() +
facet_wrap(~species)
#> Warning: Removed 2 rows containing non-finite values (stat_density).
# new order
palmerpenguins::penguins %>%
mutate() %>%
ggplot(aes(x = body_mass_g, color = island)) +
geom_density() +
facet_wrap(~factor(species, c("Chinstrap", "Adelie", "Gentoo")))
#> Warning: Removed 2 rows containing non-finite values (stat_density).