The New York Court of Appeals ordered the removal of an upstate judge who had joked to attorneys about his ex-wife's sexual preferences, among other inappropriate sexual comments, and had exposed a firearm in the courthouse.