New York Laws
Title 1 - Form of Ballots
7-116 - Ballots; Order of Names On.

(b) Except where a contest or candidate is removed from the ballot by
court order too late to make complete compliance with this paragraph
feasible, the title of each public office or party position and the
names of the candidates for such office or position appearing on any
ballot used for primary elections over which the county board of
elections has jurisdiction shall appear on such ballot immediately
adjacent to one another, either horizontally or vertically; and no blank
spaces shall separate the names of candidates actually running for an
office or party position on such ballot, and no blank spaces shall
separate any two such offices or positions which appear on such ballot
in the same column or row.
7. Whenever a county board of elections or the board of elections in
the city of New York must conduct a primary election in the respective
county or the city of New York in which separate contests for candidates
of different genders for the same party position are to be printed upon
the ballots, and when rules require these positions be listed separately
on the ballot, the respective county board of elections or the board of
elections in the city of New York shall determine by lot the order of
the various gendered contests. This lottery will be conducted separately
for each election that is separated by gender.