Yes, you are right: sleep is in the first sentence a verb and in the second a noun.
Think of the part of speech that "enough" is modifying in your sentences. In the first it's modifying a verb and "enough" is functioning as an adverb. Adverbs generally come after the verb. In the second it's modifying a noun and "enough" is functioning as an adjective (specifically, a determiner). Adjectives generally come before the noun.