def sort_keywords(keywords):
    """Sort keywords in the proper order: i.e. glob-arches, arch, prefix-arches."""
    def _sort_kwds(kw):
        parts = tuple(reversed(kw.lstrip('~-').partition('-')))
        return parts[0], parts[2]
    return sorted(keywords, key=_sort_kwds)