sp2 carbons are more electronegative (electron withdrawing) than sp3 carbons due to increased s-character. Electron withdrawing groups (EWG) make acids more acidic and bases less basic.
For this reason, piperidine (compound A) is the more basic than pyridine (compound B):
(more basic) A > B (less basic)
Nitro (-NO2) is an EWG, so 4-nitropyridine (compound C) will be less basic than compound A.
Dimethylamine is an electron donating group (EDG), so it adds electron density to pyridine and increases basicity. So dimethylamino pyridine (DMAP, compound D) will be more basic than compound A:
(more basic) D > B > C (less basic)
So how does compound A compare with compound D? There is no way of predicting this based on EWG/EDG rules alone. After all, what should be more basic: piperidine, which has sp3 carbons (increases base strength), or DMAP, which has sp2 carbons (decreases base strength) but also an EDG (increases base strength) ?
There's no way to tell. But it turns out that Piperidine is a little more basic than DMAP. So the overal order is:
(more basic) A > D > B > C (least basic)