Are there any named/famous/particularly good algorithms for organizing email messages into threads?
I'm looking to add a feature to my site similar to Google Groups (and other mailing lists) and I was just wondering if there were any published algorithms for such organizing. I know it would probably be fairly easy to roll my own, but there can be a big difference in user experience between a passable algorithm and a good one.
Bonus points for an algorithm already implemented in ruby!