A secondary rainbow is formed by two total internal reflections inside the raindrops, which reverses the order of colors compared to a primary rainbow. This results in red being on the inside and violet on the outside.