Will Riker knew he must look a bit strange in the ratty black wizard's hat, but he let it work its magic.
"…average intelligence, though a fair amount above average in cleverness—a gambler, no?—and good at bluffing, I see…somewhat Slytherin. But you have bravery, and loyalty to your captain (expected of course), and you would willingly go into danger for him, effectively eliminating Slytherin-"
"Phew," Riker said.
"—because Slytherins tend to be selfish. Too strong and bold for Hufflepuff—though you have a good heart—so…GRYFFINDOR!"
Eleven-year-old Jean-Luc Picard eyed the hat with distaste. He'd expected something more flashy and interesting, something more obviously magical for a magic school.
But, ever curious, he put it on, and was not disappointed.
"Oh, let's see…lots of potential here…you're eager, striving towards the future—oh! You have an ambition!"
"Starfleet," Jean-Luc said, feeling strange talking to a hat.
"Very Slytherin, that single-minded drive is. But personal advancement is not all—also a brave desire to explore the unknown, a keen, Ravenclaw mind, and a Hufflepuff's loyalty to moral ideals you feel Starfleet exemplifies. Such a strange combination…too much, ah, fire for Hufflepuff, too much bravery and daring for Ravenclaw, too much thoughtfulness for Gryffindor. That leaves Slytherin, but I've already said your ambition is not pure ambition…hm…Gryffindor has had intelligent members, better be…GRYFFINDOR!"
If hats could leap, the Sorting Hat would have leapt off of Deanna Troi's head.
"I do the probing around here!" the hat snapped, the first time it had.
"Sorry," Deanna said, raising her mental shields.
"No, leave your mind open!" the hat said irritably.
Deanna adjusted her mind again. "Ah, that's better…hm…intelligence and compassion…a desire to be heard and understood, but not to be heard more than others…so not much ambition. Brave, when the situation calls for it, but not daring enough for Gryffindor. Intelligent, but your true strength is your compassion and empathy, so…HUFFLEPUFF!
Worf glared at the hat, but put it on anyway.
"You don't want to do this, only your strong loyalty to your fellow crew members motivated you to put me on. That's a Hufflepuff trait, but the rest of your disposition is not very Hufflepuff. Very brave and daring, very Gryffindor, but a fair amount of guile and ambition, both Slytherin qualities. Yes, I do think you would be best for-"
"Slytherin has no honor." Worf growled.
"F-fine then, though you'd do well in Slytherin, better be…GRYFFINDOR!"
A/N Picard's Sorting is as a child because of my other fanfic "Picard in the Wand Shop" that implies that he's a wizard from birth. I honestly don't have an explanation for why the others were sorted (except for Data, see "Data in the Wand Shop").