2018 could go down in the books as a turning point in Walmart's (WMT -0.45%) business. After many years of online irrelevancy, followed by several years of intense investing in online sales capabilities and a string of acquisitions of online-only stores, the world's largest retailer now has a viable e-commerce business. Walmart's success comes in spite of recent worries about global economic slowdown, a trade war between the U.S. and China that could hit consumers in the wallet, and plenty of competition in the world of digital selling.

Amazon (AMZN -0.98%), on the other hand, continues to cool off in that department. E-commerce is still squarely in Amazon's control, but size and success often come with a target. Walmart has been increasingly willing to go head-to-head with Amazon, and its brand of online retail is narrowing the gap with the younger disruptive Amazon.

A tale of two retailers

During the first quarter of 2019, Walmart's U.S. business put up comparable-store sales growth of 3.4% -- the best rate in nine years -- for a grand total of $80.3 billion in net revenue. And 1.4% of that total growth was due to the e-commerce segment, which includes order-online pickup in-store. While still a relatively small part of the total operation, Walmart said its e-commerce sales surged 37% higher compared to a year ago.

By comparison, Amazon's numbers were pedestrian. Sales from online stores increased 10% to $29.5 billion. Meanwhile, stores from physical stores (which include the Whole Foods subsidiary) were up a meager 1% to $4.3 billion after falling 3% in the fourth quarter.

E-Commerce Growth

Walmart

Amazon

Q1 2018

33%

18%

Q2 2018

40%

14%

Q3 2018

43%

10%

Q4 2018

43%

13%

Q1 2019

37%

10%

Data source: Walmart and Amazon.

What does all of this mean? According to the U.S. Census Bureau, e-commerce grew 10.4% during the first four months of 2019. That means Amazon is still growing, but it's in line with the total U.S. nonstore retail industry overall. It's Walmart that is posting above-average expansion. Amazon, once a thorn in Walmart's side, is losing steam. Now Walmart is closing ground and retaking some of its lost market share via the digital channel.

A man entering his credit card information into a tablet he is holding while shopping online.

Image source: Getty Images.

Two very different stocks

For investors looking for retail stocks, Walmart looks like the better bet right now. The online business the company is building on top of its physical footprint is winning with U.S. consumers, and Walmart is investing heavily in overseas retail too -- including its majority-owned stake in India's largest e-commerce site Flipkart and a partnership with Japan's Rakuten. Walmart's stock is currently valued at 19.2 times trailing 12-month free cash flow and pays a 2.1% annual dividend.

That doesn't mean Amazon is chopped liver. Though its retail business isn't what it used to be, the company is using its leadership in digital selling to grow in other areas. Online advertising, for example, was a $2.7 billion segment in the first quarter, up 34% year over year. And then there's the cloud computing business Amazon Web Services, as well as other subscription services (like Amazon Prime, Video, and Music), both of which grew 41% and 40%, respectively. The two reported divisions combined for a $12 billion haul during the quarter.

Thus, Amazon is still the better growth stock here. But as far as e-commerce is concerned, it's time to start giving credit where credit is due to Walmart. An insignificant internet enterprise just a few years ago, the big-box store is now a force to be reckoned with when it comes to the future of shopping.