def sort_positions(positions):
    """
    Utility routine to take two corner values are return the x and y range.

    Parameters
    ----------

    positions:   A four element list or numpy array of float values; values
                 are assumed to be [x1. y1, x2, y2] for two corner positions
                 (x1, y1) and (x2, y2).

    Returns
    -------

    xmin:    A floating point value, the x minimum defining a rectangular area
             or None if there is an issue

    xmax:    A floating point value, the x maximum defining a rectangular area
             or None if there is an issue

    ymin:    A floating point value, the y minimum defining a rectangular area
             or None if there is an issue

    ymax:    A floating point value, the y maximum defining a rectangular area
             or None if there is an issue

    """
    if len(positions) != 4:
        return None, None, None, None
    for loop in range(4):
        if positions[loop] is None:
            return None, None, None, None
    xmin = min(positions[0], positions[2])
    xmax = max(positions[0], positions[2])
    ymin = min(positions[1], positions[3])
    ymax = max(positions[1], positions[3])
    return xmin, xmax, ymin, ymax