df.groupby(['Id']).median().sort_values("Speed").plot.bar()
Or just try to sort_values("Speed") after you aggregate them.
EDIT:
so you need to do this:
result = a.groupby(["Id"])['Speed'].aggregate(np.median).reset_index().sort_values('Speed')
and in sns.barplot add order:
sns.barplot(x='Id', y="Speed", data=a, palette=colors, order=result['Id'])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…