def METHOD_NAME(entry):
    """Return a sort key from a compositional grounding entry"""
    concepts = [grounding[0] for grounding in entry
                if grounding is not None]
    scores = [grounding[1] for grounding in entry
              if grounding is not None]
    # First key is the theme grounding
    key1 = scores[0]
    # Second key is the number of groundings
    key2 = len(scores)
    # Third key is the average score
    key3 = sum(scores) / len(scores)
    # Fourth key is alphabetical to avoid non-determinism
    key4 = '|'.join(concepts)
    return key1, key2, key3, key4