In astronomy, weight (or more precisely mass) matters. From opponents facing off in the boxing ring to galaxies harassing each other in a super cluster, battles are often won by the bigger of two opponents. While it's possible to put a person on a scale, measuring mass for distant objects is a bit more complicated. The most accurate way to measure the masses of celestial objects is to look at their gravitational interactions. Binary stars, orbiting planets, and even the two galaxies in a super cluster, all reveal their mass through their gravitational interactions — and subsequent accelerations — with other objects. In our own Milky Way, the motions of gas clouds and stars can be used to measure the galaxy's mass. This measurement is another application of Kepler's third law, which relates the orbital period and distance of an object from a system's center of mass, and the mass of the system. As you can imagine, the motions in the galaxy are very complicated. Instead of two or a handful of objects, there are many millions of stars moving over a very large region of space.
The motion of the Sun is not only affected by all the stars between us and the galactic center, but also by all the mass beyond its orbit. Trying to sort out how to take into account all this material may seem daunting, but Isaac Newton had important insights into simplifying this problem. For a spherical distribution of mass, he showed that the motion of an orbiting object is controlled only by the mass of the system that lies within the object's orbit. In the case of the Solar System, this is obvious because the Sun lies within the orbits of all the planets and so controls the motions. In the case of the galaxy, the Sun's orbital period is controlled only by the portion of the galaxy that lies within the orbit of the Sun. It turns out that the stars exterior to the Sun's orbit do not affect its orbit. The Sun in effect does not "feel" the outer regions of the galaxy.
Newton mathematically proved this assertion for any spherically symmetric mass distribution; more recent work has developed the modifications for flattened structures such as disks (the difference for galaxies is 30% or less). His simplifying assumption is very useful because it means the motions in a galaxy do not have to be fully mapped out to estimate its mass.