Major benchmarks stayed in the green Wednesday as investors weighed a continued stream of strong corporate earnings reports with disappointing housing data.

But several individual stocks easily outran the broader market, including W.W. Grainger (GWW 0.55%), Telefonaktiebolaget LM Ericsson (ERIC 0.79%), and Berkshire Hathaway (BRK.B 1.30%) (BRK.A 1.18%). Here's why they did so well.

Stock charts indicating gains overlaid on a digital world map

Image source: Getty Images.

W.W. Grainger's beat and raise

Shares of W.W. Grainger climbed 11.2% after the maintenance and repair products leader delivered stronger-than-expected second-quarter results. Quarterly revenue climbed 9.4% year over year to $2.86 billion, which translated to more than 50% growth in adjusted (non-GAAP) earnings to $249 million, or $4.37 per share. Analysts, on average, would have settled for earnings of $3.72 per share on revenue of $2.82 billion. 

"We continue to gain share across both large and medium customers and acquire medium customers amid a strong economy," stated Chairman and CEO DG Macpherson, adding that the business' turnaround in Canada is on schedule. "And the single channel and international businesses also improved operating performance." 

Grainger now expects full-year sales growth of 5.5% to 8.5% (up from 5% to 8% previously), and adjusted earnings per share in the range of $15.05 to $16.05 (up from $14.30 to $15.30 before).

Ericsson's turnaround gains steam

Ericsson stock jumped 8.3% in the wake of the Swedish telecom giant's impressive second-quarter report. Sales declined 1% year over year to 49.8 Swedish krona (SEK), which translated to a net loss of SEK1.8 billion (or roughly $204.1 million). The results were technically mixed relative to consensus estimates, which had called for a much narrower net loss of SEK261 million on lower revenue of SEK48.25 billion. But it's clear that Ericsson is pouring resources into research and development and its ongoing business restructuring. On the latter, the company laid off over 2,000 employees during the quarter, and completed an ambitious SEK10 billion cost-savings program.

"We continue to execute on our focused business strategy and are tracking well toward our 2020 target of an operating margin of at least 10%," stated CEO Borje Ekholm. "The investments in technology leadership have resulted in increased gross margin to 37% and growth in segment Networks."

Berkshire's surprising buyback news

Finally, Class B shares of Berkshire Hathaway soared 5.3% -- an enormous move for the typically stable company with a market cap of nearly $500 billion -- following an update to its notoriously stringent buyback policy.

The diversified financial holding company's board has decided that share repurchases can be made at any time that both CEO Warren Buffett and Vice Chairman Charlie Munger "believe that the repurchase price is below Berkshire's intrinsic value, conservatively determined."

For perspective, Buffett has previously insisted he would only consider repurchasing Berkshire stock if its price fell below 1.2 times book value. Incidentally, as I pointed out only yesterday, Berkshire stock was trading just above that threshold at around 1.35 times book value before today's pop. It seems, then, that even Warren Buffett shares my sentiment that the stock is still attractively valued at these levels.