Fix import syntax error
Fix sort syntax error

I don't dare try to determine what this lambda is trying to do, so let's
use a sledgehammer to make it work. This requires a Python version bump,
but we haven't released since the port to Python 3, so that's hardly a
big deal.