def get_physical_mapping(monitors):
    """
    Returns a list of Xinerama screen indices in their physical order.
    Where physical order is defined as left-to-right and then top-to-bottom.

    :param monitors:  List of (x, y, w, h) rectangles
    :rtype:           List of Xinerama indices
    """
    retval = []
    tosort = []
    for i, (x, y, w, h) in enumerate(monitors):
        tosort.append((x, y, i))
    for x, y, xscreen in sorted(tosort):
        retval.append(xscreen)
    return retval
