When building a retirement portfolio, you want to focus on companies that have shown not just longevity, but also adaptability. You want brands that have shown they can change as the market does, not companies set with one way of doing things.

Walmart (WMT -0.51%) has shown that it can be one of those companies. The retail giant could have simply rested on its laurels as the largest brick-and-mortar retailer in the world and eventually gone into a slow decline as more shopping moves online and customers demand same-day delivery. Instead, it made the sometimes painful transition to become an omnichannel business, which makes it a near-perfect pick for your retirement portfolio.

A Walmart in-store pickup tower

Walmart has tried all sorts of ways to get orders to customers. Image source: Walmart.

What has Walmart done?

Walmart could have just focused on being a really good brick-and-mortar store that offered a mediocre digital experience. For years, in fact, it seemed like that's what the company intended to do. Then, the retail giant made a surprise move in 2016. It spent $3.3 billion on Jet.com and put its CEO, Marc Lore, in charge of the company's digital business.

Lore has butted heads with other executives at the company and not all of his moves have worked (like buying pure-digital brand Bonobos), but he has changed the company's digital trajectory. Walmart stopped trying to sell two-day delivery using a model similar to Amazon. It instead offered the same service for free (albeit for many fewer items) and built supply chains to support that offering.

Walmart has also truly integrated its digital and brick-and-mortar supply chains. It can send individual orders from its stores and move inventory around effectively. The company has also steadily grown its same-day grocery delivery while pioneering innovative ways to buy online and pick up in-store (BOPIS).

Going full-on omnichannel wasn't cheap or easy, but it's an investment that has kept the company relevant. Same-day grocery delivery, one-day delivery for many items, BOPIS, and buy online, return in-store (BORIS) are becoming table stakes for the retail and grocery industries.

These efforts are paying off. Overall sales rose by 3.3% in the third quarter, and U.S. comparable-store sales rose by 6.6% in the company's home market. That was driven by a 41% increase in digital sales, according to prepared remarks from CEO Doug McMillon. His explanation sort of lays out the case for buying and holding the stock:

Our work to create a seamless omnichannel experience for customers continues. They want us to save them time as well as money. You can measure our progress in a number of areas including online grocery where we now offer pickup, delivery, or both in nearly a dozen countries including the U.S. where we now have more than 3,000 locations for pick up and more than 1,400 locations that offer delivery. We're learning a lot as we expand these services. We'll use this knowledge to inform the new capabilities we build and deepen our relationship with customers.

Big changes have been made, and evolution will continue. Walmart is still investing in its supply chain and omnichannel capacity, but it has already done a lot of the hard work.

Not every retailer has done this

Give McMillon credit for forcing his management team to take a long-term view at the expense of shorter-term margins. He bit the bullet and made investments in a business that was already working so it would be better positioned for the long term.

Many retail leaders have failed to do the same thing. The fact that McMillon was willing to bring in an outside executive and empower him to make a real change should encourage shareholders. This is a management team that won't stop evolving, which suggests that the company should be well-positioned for wherever the market goes.