def order_coords(coords, clockwise):
    total = 0
    x1, y1 = coords[0]
    for x, y in coords[1:]:
        total += (x - x1) * (y + y1)
        x1, y1 = x, y
    x, y = coords[0]
    total += (x - x1) * (y + y1)
    is_clockwise = total > 0
    if clockwise != is_clockwise:
        coords.reverse()
    return coords
Orders coordinates.
dataset/ETHPy150Open cgarrard/osgeopy-code/Chapter13/listing13_4.py/order_coords