B is correct
Here is how the spell should read:
Caster casts sleep and rolls (5d8, or more if upspelled).
All creatures within 20 feet of the spells target "reveal" their current hit points.
Starting with the creature with the lowest current hit points, they are subject to the effect of the sleep spell.
So as an example say the caster rolled a total of ...
The mechanics of "sleep immunity" means that you are unaffected by the sleep spell. This means A is correct. You do not factor them into the equation as all and ignore them entirely.
This answer supports mine, albeit using the undead's sleep immunity.
That said, there may be a difference between "immune to sleep" and "cannot be put to sleep", and the ...