def print_warnings(warnings, args):
    """Print a list of warning occurrences."""

    def key(warning):
        return (warning.file, warning.line, warning.column)

    warnings.sort(key=key)

    for warning in warnings:
        if args.first_line:
            text = warning.text.partition("\n")[0] + "\n"
        else:
            text = warning.text
        print(text, end="")