Efficient Sorting Algorithms

Draco sat comfortably at the Slytherin table staring up into the dusk sky.Clouds drifted lazily from the North and birds, starlings mostly, dartedaround. Draco watched the flock expand and contract, thoughts drifting throughconversations, weighing potential allies and enemies. Vincent and Gregory’sposition took up some thoughts, as did recent lessons from his diary, and hisearlier conversations on the train. Draco wasn’t thinking just rememberingand idly considering connections that popped into his head.

Draco’s thoughts drifted like clouds above.

Draco had already studied the head table, seating arrangements told a story.At the center sat Minerva McGonagall, black hair flowing freely under herstill stern hat. Professors Sprout and Flitwick flanked her. The Headmistresschatted with both, gazing solemnly over the assembled students. On the otherside of Flitwick sat Horace Slughorn, leaning over his own belly to chortle ashe pointed out entering students to the bored Charms instructor. Beside Sproutsat a man whose deeply scarred right cheek marred an otherwise handsome look.His red and gold robes (and seat) announced the new Head of Gryffindor. Dracodidn’t recognize him. Other professors sat on wings of the head table.Professor Burbage looked annoyed sitting next to a young-ish Muggle dressed inan oddly styled suit. The lapels were much wider, colors much bolder thansuits Draco encountered.. The Muggle’s wild black hair, thick plastic glassesand lush mutton chop sideburns looked like nothing Draco had seen in hisadmitted limited experience. Certainly no teenager he’d met dressed like that.

After taking in the head table, Draco glanced around the house tables.Slytherin’s sparseness bothered him so he stared at the sky instead.

The room quieted when the First Years entered, led by Hagrid. Draco’s eyesdrifted earthward and noticed that the Headmistress already standing. Hehadn’t heard. She gazed down at the procession of children, barely smaller butmuch less confident than Second Years. Had it really only been one year? Firstyears waved at siblings and drew themselves close into small groups under thewithering inspection of the older students who whispered, jeered, and madeclandestine bets. The Sorting Hat, placed on a small stool in front of thehead table sat silent until the children filled in the gaps between the tablesand stopped.

A small rip in the cloth revealed itself to the gasp of the First Years, andthe Hat spoke.

.

I’m the cleverest piece of leather

ever formed into a hat

And I’ve stayed the same forever

Though I change my annual chat.

.

Since the cornerstone was placed

upon the ground to start our school

The yearly opening feast must wait

while I declaim atop this stool!

.

Should you be in Ravenclaw

you’ll answer riddles by the door,

For sharpening the student’s mind

was Rowena’s favorite chore.

.

If you land in Hufflepuff,

then you’ll never lack a friend,

For Helga was the glue

that held together till the end.

.

If ‘tis Slytherin you seek,

then your reward you must chase

_For the virtue of ambition _

surely drew you to their place

.

And every Gryffindor does know

that the path righteous and true

demands the utmost bravery -

Nothing else at all will do.

.

But I have a secret request

That I choose now to reveal:

_Consider those whose grand bequest _

created Hogwart’s Mighty Seal.

.

_Look closely at our Founders - _

consider their full history -

You’ll find extended meanings

and glimpse a subtle mystery.

.

For Rowena was ambitious,

And Salazar was brave,

And Godric fiercely loyal,

Helga clever to her grave.

.

Each founder has more character

than we remember every day

Do not oversimplify the

complex virtues they display.

.

What use is noble bravery

if you cannot tell what’s right?

.

What will you do with cleverness

when you’ve lost the will to fight?

.

How will your true ambition taste

when you’re lonely at the end?

.

And if you do nothing at all

Who would want you as a friend?

.

Tho’ our Founders have their virtues

Each exhibits certain flaws

Yet my magic is constrained

to Sorting strictly by their Laws.

.

So I am a simple top piece

Bound to my appointed task.

You can ponder, you__ can question;

That is from all of you I ask.

.

Know Thyself! For You are Deeper

than the Sorting I do voice,

I am not your only Keeper

You do daily get a Choice.

.

Hear me Teachers! Hear me Students!

I do finish now my Song.

Those who state opinions firmly

May still be completely wrong.

.

When the Hat began the hall sat rapt and silent, first years stunned by theHat itself, everyone else by the message. When the Hat named each House theirtable cheered (not too loud, everyone knows the Hat does not pause). As thesong continued into the founder’s flaws whispering started. Professor Slughornlooked nervous; might the Hat dare abolish Slytherin altogether? The murmursrose until the Headmistress’ harsh _Shhshh _quieted everyone.

As the last word resounded in a silent hall, Draco looked around. Scatteredclaps sounded after a few seconds, nothing like the rambunctious applauseafter last year’s song. What had the hat meant? The Hat had reminded him thateach Founder possessed virtues the others espoused. Why?

Professor Flitwick, holding a scroll, said “Creevey, Colin” and Draco’s eyessnapped back to the Sorting, all polite attention. The Hat had said ’Yet mymagic is constrained.’ The Hat chose. That’s what it did. Colin went intoRavenclaw. Draco focused on the words as several other students got chosen.One went into Slytherin, which distracted Draco as he clapped and tried toremember the boy’s name. That wasn’t a good sign. The hat picked the dominantvirtue; everyone had a mix of virtues; the Hat did its best. Draco’s thinkingwent in circles.

The blond girl - so that was Luna Lovegood - went to Ravenclaw. Dracosnorted.

The Hat admitted it could be wrong. It couldn’t come out and say “I’m wrong,sometimes” so it stated that people could be wrong, but the meaning was clear.Draco’s eyes narrowed. He should be in Slytherin. He wanted to be inSlytherin. But others thought “Anywhere but Slytherin…” and the Hataccommodated them the best it could.

Did the Hat regret that? Or did it regret putting anyone into Slytherin?

“Smith, Zacharias” spent a slow minute under the Hat’s brim before winding up,surprisingly, in Hufflepuff. Draco scanned the crowd for wrongly sortedstudents, looking to find those who should have been in Slytherin. But hecouldn’t think of any. Vincent and Gregory were saying something and his eyessettled past them, onto Pansy Parkinson. Could he get rid of her? Should he?He glanced around the Hall, again. Mike from Hufflepuff had potential…hethought about the problem.

Draco realized he couldn’t solve it. Nobody wanted to be in Slytherin afterlast year.

“Weasley, Ginevra” was sorted into Gryffindor to the cheers of herrambunctious siblings. Apparently she was the final student because theHeadmistress was getting ready to speak.

Draco realized he could solve another problem and stood up. At first, onlynearby students looked at him as he took a deep breath. He made no motion todraw attention to himself, other than standing up, and hoped that it would beenough.

“Mr. Malfoy?” Headmistress McGonagall’s voice sounded … mild.

“The Hat said it made mistakes. We should let students who think the Hat gotit wrong sort again.” This set off loud conversations. Draco could hear theshock and Macnair kicked him hard under the table, hissing “We’ll have noHouse left!”

Draco ignored the pain “It’s against tradition, but the Hat practically beggedus…”

The Headmistress cut him off. “Very well. Does anyone wish to be Sortedagain?”

Silence. Nobody wanted to go first, and Draco couldn’t volunteer.

Father’s training allowed him to stand up, to speak in front of others, todraw attention to himself. He’d ignored fear and shame often enough, though hefelt it. For others, it must be paralyzing. Draco walked to the stool andpicked up the Hat, carefully keeping it below his head at all times, thenquickly returned to Slytherin table, stopping in front of Vincent. Draco heldout the Hat.

Crabbe shook his head. “I can’t. I shouldn’t.”

Draco slowly raised the Hat, “You’d be happier. Let the Hat sort again.”Crabbe gave a short nod and Draco dropped the Hat on his head before Vincechanged his mind. Draco had a few steps to get back to his seat. Thewhispering had started when the Hat cried out “Hufflepuff!”

The Hufflepuff table broke into applause, joined by Gryffindor and Ravenclaw.Fred Weasley shouted “That’s the bravest thing I’ve seen!” and sounded like hemeant it. At the Slytherin table only Draco and Gregory clapped. Draco wouldhave to pretend to lose in the near future, he realized.

Vincent moved to the Hufflepuff Table, wiping his face. He passed the stool,still wearing the Hat, and went back to place it but Padma Patil caught upwith him and politely held out her hand. Vincent handed it to her, bowing witha small smile. Padma plonked the Hat firmly on her head with no ceremony.

Draco held his breath, hoping. Padma had been his second in command, afterall…

“SLYTHERIN!” came the shout, and Draco clapped, whistled and shouted with restof the table, except for Pansy Parkinson. Padma’s twin Parvarti, sat atGryffindor, mouth agape and clapped slowly.

When Ginevra Weasley stood up the entire Gryffindor table gasped, and shequickly went into Ravenclaw. At that point the Headmistress stood up.

“Miss Weasley, kindly return the Hat to its place.” She held up her hand. “TheHat is available for the duration of the Feast and I, for one, am famished.”She clapped her hands twice and the food appeared as Ginny unceremoniouslydumped the Hat before rushing to Ravenclaw. She sat next to Luna, who had beensitting alone. Draco tore into a roll and ate.

That had worked out surprisingly well. Vincent would be happier with morefriends and less pressure. Padma’s surprise had probably saved him at leastone beating and meant that there were students, good students, who heldsympathy. Draco smiled and ate.

The professors, who normally ate with polite small talk, had an animateddiscussion that he couldn’t quite hear. Professor Burbage filled in the Muggleon details. Draco wasn’t positive, but thought The Headmistress had toldFlitwick and Slughorn to cool it. The new Head of Gryffindor stared at Dracoand a few other students, just eating, no conversation. During the meal threemore students went under the Hat, each time causing a hush. Fred Weasley ormaybe George sauntered forward just before desert before breaking into a smileand jogging back to his seat under a small barrage of buttered dinner rolls.

After finishing off some iced cake Draco went up and grabbed the Hat, againkeeping it low to signal that he wasn’t going to put it on. He walked to theRavenclaw table, eyes locked firmly on Harry Potter.

Harry tried to wave him off but Draco went past Harry and stopped in front ofHermione.

He’d planned a small speech on his walk over. You are incredibly clever, butnot enough to convince me that the Girl who stood up to bullies, Dumbledore,Voldemort and Azkaban is rightly sorted. But as he walked over, he realizedit didn’t need to be said.

“You’d never brag,” Draco explained.

Hermione blushed. Draco raised the Hat slightly and paused, just in case sherefused. Draco placed it gently on her head and “GRYFFINDOR” rang outinstantly with enough force to shove Draco backwards.

The hall exploded into applause and Hermione stood up, as boys patted her armand girls pulled her into hugs. Draco took the Hat off her head and walkedback onto the podium. As he sat down he mumbled “Let’s see Ravenclaw win theHouse Cup now,” to nobody in particular.

Harry Potter stood up from the middle of the Ravenclaw. “I promised the HatI’d never wear it again,” which sparked murmuring in the hall and a full-blownfive hour debate in the Ravenclaw commons room later that night. “But givenit’s pronouncement, I’d like to alternate between Ravenclaw and Slytherin.”

Of course you would, Mr. Potter,” said the Headmistress. She motioned forhim to change seats as the students laughed and a few snaps echoed around thehall. “Anyone else?

Colin Creevey switched to Slytherin, which concluded Hogwart’s first Re-sorting.


Author’s Confession - I originally wrote these early chapters as a mood piece, and now consider them a prologue. Since I’ve gotten good response and I’m enjoying writing this, I’m continuing and play to write out a full year. I’ll probably have to take some breaks for that.

For the extended story I’ve got a good plot, mostly consistent. But I see gapsI can’t easily fill. I might be able to do it, but it would make the storyworse. I’d be adding epicycles, I fear.

My options are to delay until I can bulletproof it or just enjoy the story.Since I stop writing when considering the parts that give me trouble, I’vedecided to just keep my momentum and hope that I’ll spot a solution withoutagonizing, and accept that there may be some handwaving if I fail. (I findideas arrive easiest when I don’t force them, a theme played out in Draco’sdaydreaming above, which I wrote weeks ago).

If, at the end of the story you say “But… but… but…”, know that I am wellaware of several issues and probably missed more, and I wish I could dobetter.

This is a complex plot, but it’s entertainment (hopefully) and writingpractice. Constructing a perfect puzzle isn’t my motivation. Also, I believethe world is an ambiguous place. So questions like “Is Hermione anOcclumens” (on the train scene) may not be answered early (or ever).

(“Such is Realism.”)

In most cases I have answers to those questions in mind when I write the scene(I did for that particular example). Sometimes I flub it, though. I will showscenes without Draco to clear things up more (after the prologue), but notevery question will be answered. After answering that particular question Idecided that I’m going to, in general, let the work speak for itself exceptfor the cases where I realize that I’ve fallen to the Illusion ofTransparency, then I’ll answer and revise (or if I’ve made an easilycorrectable blunder). I’m not going to defend the decisions in real time, inpart because it gives away too much, and it’s just not practical.

If you treat this story as a perfect puzzle, at the end you may discoverpieces missing. Or poor connections.

I hope you enjoy the picture, though.

I’d like to put a puzzle in, and there will be puzzles, but that’s not in anyway my primary goal.

Consider this fair warning.


Subscribe to the weekly digest of our best stories!

If you like this site, you should check out my other projects:


Login to leave a comment.
Success! Thank you for subscribing!