Blue vs Pink

I thought this was a interesting meme. As a society, colors are assigned to girls and boys. But why? Where did this idea come from? I once heard that in the past it was the opposite. Blue was for girls and pink was for boys. As I got older I noticed that if men were to wear pink, their sexuality was in question. For girls, this was never the case. Over sometime, men have felt free to wear the color pink without their sexuality being questioned, which is great but still crazy to me because it all had to do with what color they decided to wear.