Return labels sorted in a default order suitable for NER tasks:

    >>> sorted_for_ner(['B-ORG', 'B-PER', 'O', 'I-PER'])
    ['O', 'B-ORG', 'B-PER', 'I-PER']

def sorted_for_ner(crf_classes):
    """
    Return labels sorted in a default order suitable for NER tasks:

    >>> sorted_for_ner(['B-ORG', 'B-PER', 'O', 'I-PER'])
    ['O', 'B-ORG', 'B-PER', 'I-PER']
    """
    def key(cls):
        if len(cls) > 2 and cls[1] == '-':
            # group names like B-ORG and I-ORG together
            return cls.split('-', 1)[1], cls
        return '', cls
    return sorted(crf_classes, key=key)