Replaced SequenceMatcher computational complexity sorting with more readable code