def _sort_kw_matches(skw_matches, limit=0):
    sorted_keywords = list(skw_matches.items())
    sorted(sorted_keywords, key=cmp_to_key(_skw_matches_comparator))
    return limit and sorted_keywords[:limit] or sorted_keywords