Environment map importance sampling (beginner)
From all other implementations I have seen, you generally sample twice, once in the Y dimension to select a row and then once in the X dimension to selct the pixel from this row.
I am not sure if this is necissary, maybe you're one dimensional sampling is fine.
I think you also need to multiply your pdf so that it is relative to solid angle (so it's total sums to 4pi).
You should be able to do this by dividing by (2 * Pi * Pi * sinTheta).
PBRT is probably the best textbook to help you. You can find it online here:
http://www.pbr-book.org/
The source code is also available. Here is the code for the environment light:
https://github.com/mmp/pbrt-v3/blob/aaa552a4b9cbf9dccb71450f47b268e0ed6370e2/src/lights/infinite.cpp
and the code for the Distribution2D sampler:
https://github.com/mmp/pbrt-v3/blob/aaa552a4b9cbf9dccb71450f47b268e0ed6370e2/src/core/sampling.h