How do birds sleep?

before my rainbow lorikeet goes to sleep he goes through these 4 steps:
1 first he opens his right wing horizontally stretches his right leg, he then dose the same with his left wing and left leg.

2 he then opens his top part of his beak[ the part he breaks [bankser flowers with] and then his bottom beak and yawns.
3 he then preans his feathers [so there nice and soft]
4 and then he lays his head [by this time you can not see his head] which is faceing his back. he is now asleep.
please note: the guide line i have given you works with almost every single bird no matter what species it is.

These tiny creatures must always be alert for predators, ready to dart away at a moment's notice. The best that many of them can hope for are short little bursts of sleep.

Sleeping habits can also change with the seasons. Birds tend to sleep in the same areas they inhabit during the day. For instance, territorial birds often sleep on their nests, during the breeding season but now in the fall might sleep communally in large roosts. Water birds will sleep sitting or standing on the shore, or in the water or on predator-free islands. Tree-dwellers prefer to sleep in trees or dense shrubs out of a predator's reach.

When birds are tired, they scrunch down to sleep because that automatically makes the toes grip their perch and stay locked. In the legs of tree-dwelling birds, the tendons from certain muscles extend down the leg behind the ankle to attach to the tips of the toes and when their knees bend, the tendons are pulled taut, making the toes on their feet clench.

Some birds can also sleep with only half a brain and one eye open, always on the lookout for danger. Keeping one half of the brain at rest is called unihemispheric slow-wave sleep (USWS).

Along with finding a safe place from predators to catch a few winks birds also need protection from the weather. Birds fluff their feathers to create many tiny air spaces that drastically reduce heat loss (the same principle that makes down jackets so warm in winter) and bury naked body parts into their feathers. This is why many birds pillow their head on their shoulder with their bill tucked among downy back plumage and have one leg held tightly up against the body.

Birds can also begin a constant shivering called thermogenosis to produce heat five times that of their normal rate, helping them to maintain an amazingly high body temperature. Scientists have found that some birds like chickadees go even one step further to survive the cold winters. The birds go into a nocturnal torpor to conserve energy. Torpor is a kind of deep sleep accompanied by drastically lowered body temperature, heart rate, and breathing. The result is a controlled hypothermia that can save a bird up to 20% of its energy. (Hibernation is defined as a sustained state of torpor.)