更改R中的堆积条形图顺序

我目前正在绘制堆叠的条形图,并希望更改不同零件的显示顺序。这是我的图形当前的样子:

enter image description here

当前代码:

#top 10 countries with the most medals between 1924-2000, all seasons, broken down by medal type
maingraph2 <- cleaneddataset %>% 
  group_by(NOC,Medal) %>% 
  summarise(MedalCount = sum(MedalCount))

maingraph2 <-maingraph2[order(-maingraph2$MedalCount),]
maingraph2graphdata <- subset(maingraph2, NOC == 'USA'| NOC == 'URS'| NOC == 'SWE'| NOC == 'ITA'| NOC == 'HUN'| NOC == 'GER'
                             | NOC == 'GDR'| NOC == 'GBR'| NOC == 'FRA'| NOC == 'AUS')



ggplot(sorted, aes(x = NOC, y = MedalCount))+
  geom_col(aes(fill = (Medal)), width = 0.7)

Snipped of graphing data: enter image description here

我希望条形图从上到下的顺序为金(绿色),银(蓝色)和青铜(红色)。我在网上找到了其他建议来更改列顺序,但这只是颠倒了顺序,使Gold仍然处于中间位置。

感谢您的时间!