Sorting Hat is an old enchanted talking hat that will decide the fate of new students in Hogwarts School of Witchcraft and Wizardry.
Before Sorting Hat was hexed by Hogwarts founders it belonged to Godric Gryffindor, one of the original founders of Hogwarts. He was one of the wisest and one of the strongest wizards of his time. He was also good wielding a sword. Sometimes when he had a Muggle-born opponent he would fight him only using his sword. Before he died he and the rest of the founders came to an agreement that they will bewitch his hat and use it to help make decisions in sorting first-year students in one of the four houses.
Sorting Hat will be put on your head and it will listen to your thoughts and understand your true personality. It will take the hat some time to process your thoughts and decide if you belong to Gryffindor, Hufflepuff, Ravenclaw or Slytherin. When it is done thinking, Sorting Hat will speak his opinion out loud so every student and professor can hear. Sometimes it will take the Sorting Hat over 5 minutes to interpret your thoughts and that is called a Hatstall (Sorting Hat can't decide what house you belong in).
But in the mobile game Harry Potter: Hogwarts Mystery you can freely choose what house you want to be sorted to.