Every WebElement have getLocation() method. You can get X and Y of first element, then get X and Y of another element. After that just compare it to check which element is going first, and which is next one.