What happened

Shares of consumer electronics retailer Best Buy (NYSE:BBY) have surged 31% year to date, according to data from S&P Global Market Intelligence. The stock rose along with the market during the first half of the year, and a strong first-quarter report in May helped propel it to a new all-time high.

So what

Best Buy's successful turnaround began in 2012. The company slashed unnecessary costs, mostly by removing layers of management and making its supply chain more efficient. It also lowered prices and invested in its e-commerce business.

A Best Buy employee helping a customer.

Image source: Best Buy.

Best Buy's first-quarter results demonstrated the pay-off of these actions. U.S. comparable sales rose 1.4%, while international comparable sales jumped 4%. Best Buy's only international markets are Canada and Mexico, following its exit from China and Europe over the past few years. Appliance sales were a standout, with a 4.2% comparable sales increase in the U.S. and a 37.9% comparable sales increase internationally.

Best Buy's adjusted earnings soared 39.5% year over year to $0.60 per share. Domestic gross margin was up 60 basis points on an adjusted basis, and domestic adjusted operating costs were down 10 basis points as a percentage of revenue. Share buybacks also helped the cause, with the outstanding diluted share count dropping 3.6% year over year. Best Buy plans to spend a total of $3 billion of share buybacks over the next two years.

Best Buy's online sales surged as well, up 22.5% year over year. The company has managed to hold its own against Amazon.com by becoming more competitive on price, revamping its website, and speeding up delivery times by shipping orders directly from its stores.

Confidence in Best Buy as a retailer that can survive the current retail upheaval is growing with each positive report from the company. Barron's in May called the company a retail survivor, and Piper Jaffray sees Best Buy as a potential leader in the connected home category.

Now what

Best Buy produced adjusted earnings of $3.56 per share in 2016, putting the P/E ratio at about 15.7. This, however, ignores the excess cash on the balance sheet. Backing out that cash, Best Buy's P/E ratio falls to just 13.7. The stock isn't particularly expensive, especially compared with the S&P 500, which currently sports a P/E ratio in the 20s.

Best Buy stock could certainly keep rising, although further cost-cutting will be difficult given how much cost has already been removed. Earnings growth doesn't need to be all that quick to justify the current valuation, but any sign that Best Buy is losing ground to Amazon could send the stock tumbling.

Timothy Green owns shares of Best Buy. The Motley Fool owns shares of and recommends Amazon. The Motley Fool has a disclosure policy.