As far as i know, for desktop, sleep transitions to hibernation(hybrid mode) so even if power is suddenly cut off. All running documents or processes are saved and will continue running when the desktop is turned back on.
Now for Laptops. If the laptop is put to sleep and suddenly it loses power. Does it also make an auto hibernate mode? or any running applications are lost in the process?