In this task, you need to reverse all words of a given length in the sentence. The number of letters in a word determine its length. For example, the length of the word "apple" is 5.

Sentence: 'a cat and a dog laying with their head next to each other'. Reverse all words of length '5' in the given sentence.
a cat and a dog laying with rieht head next to each rehto