The dilemma has existed for years. How does society best address the challenge posed by mentally ill prison inmates — especially now, as the number of them is steadily increasing?

And now comes the refreshingly simple solution offered by New York City Mayor Michael Bloomberg: How about a more concerted effort to keep them from becoming incarcerated in the first place?

Mr. Bloomberg has ordered city corrections officials to steer people with mental health problems into treatment rather than to jail.

Others should take notice. It costs about three times as much money to lock up a mentally ill inmate as it does to imprison one without psychiatric problems, for one thing.

Once in confinement, those who are mentally ill — about 36 percent of New York City's jail inmates — are more likely to have the adjustment problems that lead to more serious disciplinary issues. They also are likely to get locked up for twice as long as other inmates who are in jail for similar offenses.

That has Mr. Bloomberg taking a close look at their incarceration. Criminal defendants who authorities believe will not skip court appearances, otherwise violate conditions of their bail or get rearrested will be recommended for supervised treatment rather than jail time. All the problems with having mentally ill people confined under such difficult circumstances can be avoided — or so Mr. Bloomberg envisions.

What if state officials saw the situation that way? Currently, roughly 8,000 of New York's 55,000 prison inmates are mentally ill. Yes, many of them are there for offenses too serious to preclude confinement altogether. But more of a effort needs to be made to consider the consequences of putting mentally ill inmates into an environment that's even more forbidding than most of New York City's jails.

It's all but impossible to imagine, for instance, mentally ill state prison inmates confined to the horrors of The Box — solitary confinement — if the Cuomo administration's philosophy were more like Mr. Bloomberg's. Yet here's New York, still managing to find justification for sending its most tortured inmates into solitary for 23 hours a day. Nothing can deter that, it seems — not a ban on such a barbaric practice announced by then-Gov. Eliot Spitzer, nor a lawsuit by the New York Civil Liberties Union. At least, not yet.