The Sorting Hat is a sentient hat at Hogwarts that magically determines which of the four school Houses each new student belongs most to. These four Houses are Gryffindor, Hufflepuff, Ravenclaw, and Slytherin. The Sorting Hat originally belonged to Godric Gryffindor, one of the four founders of Hogwarts. It normally stays in the Headmaster's office until it is needed.
Learn more on Harry Potter Wiki