Sticky Posts in Category Pages

How do we get sticky posts to “stick” to category pages? The answer to this question turned out to be much more involved than I had imaged. After scouring the internet/codex I managed to cobble together this solution.