There's a few parts to this question. When the Sorting Hat was on Harry Potter, it picked up the part of Voldemort's soul and suggested Harry would do well in Slytherin, but went with Harry's interest in Gryffindor instead. This shows the Sorting Hat does not always have a quick and easy answer and that some decisions are more difficult than others. That leads to several questions:
- Does the Sorting Hat take into account the student's stated desires when making a decision?
- Does the Sorting Hat ever get stumped on where to put a student?
- Does the Sorting Hat ever ask for a student's preference to resolve an "even-split" decision?