The federal government took the F. W. Woolworth Co. to court yesterday and obtained a consent order preventing the retailing chain from continuing to sell children's sleepwear treated with Tris, a flame-retardant feared to cause cancer.

Woolworth agreed to the order last night after the Justice Department filed a civil suit in U.S. District Court in New York charging the company with failing to comply with the ban on the sale of Tris-treated garments ordered by the Consumer Products Safety Commission on April 7.

The suit alleged that Woolworth stores in 14 metropolitan areas from coast to coast were selling products treated with Tris as recently as Saturday. The commission said these areas included that of Washington, where the banned clothing had been found in Woolworth stores in the District and Alexandria.

The specific store locations were not listed in the suit, and lawyers for the government and company refused last night to identify them. There are 16 Woolworth or Woolco stores in the Washington area - five in the District, three in suburban Virginia and eight in suburban Maryland.

Under the consent decree, Woolworth agreed to comply fully with the commission's ban and to repurchase Tris-treated garments sold by its stores. It also agreed to pay part of the cost of the commission's investigation in an amount up to $5,000.

Earlier yesterday, Woolworth President Edward F. Gibbons issued a statement saying he was ordering all the chain's stores to halt sales temporarily of all children's sleepwear and remove such items from open stock. Gibbons said the ban would continue until the company is able to determine "what is clearly and legally compliance."

A spot check late yesterday of the Washington-area Woolworth stores indicated that local managers were following Gibbons' orders. In the store at 3200 14th St. N.W., for example, every bin labeled "infant ware" was empty, with the packaged sleepware - piled hastily into shopping carts and boxes.

Store officials confirmed that they had removed the items as soon as word was received from Woolworth's corporate headquarters in New York. A check of the removed items showed that some of them contained acetate, a synthetic fiber.

The commission considers that all acetate and triacetate in children's sleepwear has been treated with Tris, a chemical substance that had been widely used to make clothing fire resistant. However, the National Cancer Institute since has reported that Tris has cancer-producing properties and could cause harm if absorbed through the mouth or body surfaces by small children.

Commission officials said the suit arose from surveys conducted around the country to determine whether retailers were complying with the ban. The test, the officials said, was whether stores were still stocking sleepwear containing acetate or triacetate.

Initially, the added, approximately 20 per cent of the stotes surveyed were found to be still selling such items and were warned that they must be removed.

During a follow-up survey last week, the officials said, Tris-treated sleepwear was found in a Woolco store in Arlington, Tex. On Saturday, Woolworth stores in all parts of the country were rechecked.

In addition to Washington, the officials said, banned garments were found in Woolworth stores in Atlanta, Boston, Bayshore, N.Y., New York City, Chicago, Cleveland, Dallas, Denver, Kansas City, Minneapolis, Phoenix, Philadelphia and Seattle.

H.P. Smith, a Woolworth corporate spokesman, said in a telephone interview that the company had made a conscientious effort to comply with the ban after it was originally announced. However, Smith said, instead of removing all garments containing acetate triacetate, the company had given orders to remove only those items identified by manufacturers as having treated with Tris.