The Los Angeles Lakers’ defense came to Phoenix like a magic carpet that figured to sweep up a Suns offense that has been in a five-game funk.

But even a wave of early fast-break points was not enough to get the Suns’ offense back on track.

The Suns made a fantastic in-game trade, losing rookie Alex Len to a flagrant foul 2 for a breakaway foul to the head of Nick Young, who was ejected for an open-handed strike to Goran Dragic’s head after Young shoved Len.

Even that backfired as the Lakers pulled out to a 13-point lead after getting torched for 120 points per game in their previous five losses.

From then on, the game became just what the Suns needed for the offense and the standings in a 121-114 victory Wednesday night at US Airways Center.

The Suns closed the first half with an 11-2 run and outscored the Lakers 67-56 in the second half. They scored 78 points and shooting 56.6 percent over that stretch of 26 minutes, 45 seconds to finish with their season’s second-highest point total. They had been shooting 40.4 percent until that point, much like their 39.5 percent shooting on the 1-4 trip.

“We were kind of working the kinks out (Wednesday),” Suns power forward Channing Frye said.

“We usually say good teams don’t lose three in a row, but we’ll say good teams don’t lose four in a row. We’re constantly learning and we’re adapting. It was a tough trip, but we’re home now and it’s for us to get that grit back in our game.”

The Lakers (14-25), losers of 12 of their past 13 games, were still able to tie the Suns (22-16) twice in the fourth quarter, but the Suns scored on nine consecutive trips to secure the win. The first eight came in the paint, where the Suns had a season-high 64 points (they average 41).

After what he called the worst game of his career when he made 2 of 16 shots Monday night at New York, Suns guard Gerald Green made 12 of 18 shots for a season-high 28 points. Only six points came on 3-pointers as he drove more and the Suns pounded the paint further with Markieff Morris’ 24 points and Frye’s 20.