On the wild grass, there are often fibrous tendrils that can cling to the fur of animals that brush against them. This allows the seeds to spread far from the parent plant. Farmers have taken advantage of this characteristic, developed through millions of years of survival struggles, to eliminate the seeds of these weeds.
They use magnets to separate the rough seeds of wild grass from the smooth seeds of beneficial plants such as hemp and black nightshade. If iron filings are sprinkled into a mixture of crop seeds that include weed seeds, the filings will attach firmly to the rough weed seeds but not to the smooth crop seeds. The mixture is then exposed to a sufficiently strong electromagnet. This process will automatically separate the crop seeds from the weed seeds: the magnet picks up all the seeds that have attached to the iron filings from the mixed seed batch.
(According to the book “Fun Physics”)