Use max() to choose longest match

Theoretically this is more efficient than using sorted().
Merge pull request #6 from tdryer/tdryer

Use max() to choose longest match