The Dance of the Railroad Track Worker. The following is adapted from wikipedia.
Gandy dancer is a slang term used for early railroad workers who laid and maintained railroad tracks in the years before the work was done by machines. The British equivalents of the term gandy dancer are “navvy” (from “navigator”), originally builders of canals or “inland navigations”, for builders of railway lines, and “platelayer” for workers employed to inspect and maintain the track. In the U.S. Southwest and Mexico, Mexican and Mexican-American track workers were colloquially “traqueros”.
There are various theories about the derivation of the term, but most refer to the “dancing” movements of the workers using a specially manufactured 5-foot (1.52 m) “lining” bar, a “gandy”, as a lever to keep the tracks in alignment.
Though rail tracks were held in place by wooden ties (sleepers outside the U.S.) and the mass of the crushed rock (ballast) beneath them, each pass of a train around a curve would produce a tiny shift in the tracks. If allowed to accumulate, such shifts could eventually cause a derailment.
The process is explained at the Encyclopedia Alabama folklore section:
“Each workman carried a lining bar, a straight pry bar with a sharp end. The thicker bottom end was square-shafted (to fit against the rail) and shaped to a chisel point (to dig down into the gravel underneath the rail); the lighter top end was rounded (for better gripping). When lining track, each man would face one of the rails and work the chisel end of his lining bar down at an angle into the ballast under it. Then all would take a step toward their rail and pull up and forward on their pry bars to lever the track—rails, crossties and all—over and through the ballast.”