import locale


def sort_func(row1, row2):
    """Compare two rows to determine which should be first. Sort them
    alphabetically by podcast title.

    Parameters
    ----------
    row1 : Gtk.ListBoxRow
        The first row
    row2 : Gtk.ListBoxRow
        The second row

    Returns
    -------
    int
        -1 if row1 should be before row2,
        0 if they are equal,
        1 otherwise
    """
    if row1.podcast.title is None:
        return 1
    elif row2.podcast.title is None:
        return -1
    else:
        return locale.strcoll(row1.podcast.title, row2.podcast.title)