def get_apiorder(ndim, latitude_dim, longitude_dim):
    """
    Get the dimension ordering for a transpose to the required API
    dimension ordering.

    **Arguments:**

    *ndim*
        Total number of dimensions to consider.

    *latitude_dim*
        Index of the latitude dimension.

    *longitude_dim*
        Index of the longitude dimension.

    **Returns:**

    *apiorder*
        A list of indices corresponding to the order required to
        conform to the specified API order.

    *reorder*
        The inverse indices corresponding to *apiorder*.

    """
    apiorder = list(range(ndim))
    apiorder.remove(latitude_dim)
    apiorder.remove(longitude_dim)
    apiorder.insert(0, latitude_dim)
    apiorder.insert(1, longitude_dim)
    reorder = [apiorder.index(i) for i in range(ndim)]
    return apiorder, reorder