The New York City Sanitation Department was established in 1860. Prior to that time, the city had no real trash collection system. Instead, herds of roaming pigs were allowed to do the job. Garbage was simply dumped out in roadways and alleys, and the pigs ate of it what they could, including the ubiquitous horse droppings that were everywhere. Wall Street was particularly overpopulated with refuse-eating swine.
Using pigs was far from perfect. In the rain the streets became pits of disease-ridden goo, the pigs became rabid and feral (and in poorer areas sometimes ate small children), rats "big enough to wear saddles" competed with the pigs, and the muck all found its way into the city's water supply, causing typhoid and a dozen other infectious diseases even among the city's upper classes.
Given New York's population explosion of the 1840s (Irish and German immigrants arrived by the million), the decision to employ humans as trash collectors came late to City Hall. But since 1860, the Sanitation Department has traveled every highway and byway of New York City in safe neighborhoods and bad, in all kinds of weather on a daily basis, keeping the city (relatively) clean.