Why are large planets away from the Sun and smaller planets near the Sun?

In school, we are taught that every planet attracts every other.

$$F=G\frac{mM}{R^2}$$

Stars have a large gravitational force and it attracts every large object.

Every planet has a different mass and travels in an elliptical orbit.

They have a specific orbit because of rotation of a planet which provides angular momentum and keeps it away from the sun at a specific distance and prevents it from going into the sun.

Why are large planets away from the Sun and smaller planets near the Sun? As attraction between large planet is large so larger planet should be closer to the sun but it is reverse of that.

I don't understand till now, why it is like this.

• Where exactly planets end up in a solar system has a lot to do with the evolution of the protoplanetary disk and also planetary migration. You might want to check that out (en.wikipedia.org/wiki/Planetary_migration) – rtime Feb 18 '17 at 8:47
• The acceleration caused by gravity (which is what is important) doesn't depend on the planet mass. – Rob Jeffries Feb 18 '17 at 16:51