The easiest option is to tilt a piece of wood cut to the height of the shelf into place to prop the shelf back to it's original height.
This will cut the long shelf into smaller shelves. This gives a lot of overall support.
The second solution would be to add a support to the back of the shelf. This solution will work best if the shelf is sagging slightly. Measure the back wall of the bookcase and cut a piece of molding to span the entire length of the shelf. Use finishing nails to tack the support into place and then paint or stain to match the surrounding shelves.
If the sag is more severe, you'll need to add support to the front and back of the shelf. For this option you will want to add a decorative piece to the front of the shelf to hide the support pieces.
Now just fill the nail holes and touch it up with some paint. That's all there is to fixing up those sagging shelves. I'm Mrs. Fixit and it's just that simple!