When i get my rotation i wanna find if it is closer to 180 or 0 or 90 or -90 in the x axis

I want to have the player landing i want to find if its closer to 90 or - 90 or -180 or 180 or 0 and rotate it to that

Something like this: