I think that you need to compare slope, not x-coordinates, and you'll probably have to break into cases of zero, positive negative, and infinite slope. E.g. if both slopes are positive, the clockwise one is the one with the smaller slope. If both slopes are zero, pick the one with the smaller x-coordinate, etc.