def label_sort_key(label):
    """
    A sort key that encourages more useful labels to come first, when we don't
    have a more solid basis to decide.

    * Prefer words starting with digits over words starting with letters:
      '101' is better than 'ci' or 'one hundred one'.
    * Prefer words ending with letters over words ending with digits:
      'hassium' is better than 'atomic number 108'.
    * Prefer lowercase words over capitalized ones: 'huge' is better than
      'Brobdingnagian'.
    * Prefer longer labels over shorter ones, as they're probably more
      specific: 'Paul Newman' is better than 'Newman'.
    * All else being equal, prefer the first label in alphabetical order.

    This is, fortunately, not the only way to choose labels. If a WordNet
    synset has a "sameAs" link pointing to a named synset in WordNet 2.0, we
    use that name, letting us use the label "United Kingdom" instead of
    "United Kingdom of Great Britain and Northern Ireland".

    However, we disregard the synset names for people, as they tend to be just
    the person's last name, and therefore are highly ambiguous in a way that
    won't be disambiguated by adding the category "person". For people, we
    apply this rule no matter what, choosing their longest name.
    """
    return not label[0].isdigit(), label[-1].isdigit(), not label.islower(
        ), -len(label), label
