Sagging. If there is no support in the middle of the shelf, nail a strip of wood about 1" thick to the wall under the shelf. This should be 16" long or more so that you can nail through to two of the studs (which are spaced roughly 14" apart). An alternative is to screw an iron angle to the wall (the screws must enter a stud).
If the shelf is warped as well as sagging, install a metal shelf support (like an iron angle but larger) under it. Or put a screw eye in the front edge of the shelf in the middle of the sag; install another screw eye in the ceiling overhead, and connect the two by a stout wire.
Note. Do not support a warped shelf from a stable shelf in this way, because it will only result in warping of the upper shelf.