Dale Sveum didn’t exactly walk into an ideal situation when he got the job as Cubs manager in 2012. He certainly wasn’t as fortunate as St. Louis Cardinals skipper Mike Matheny was in his first season.

Matheny inherited a defending World Series champion. Sveum got a mismatched collection of parts formed under a new regime with a mission of tearing down and ­rebuilding.

But does adversity at the start of a career have an upside in the long run?

“There’s definitely a lot more to learn when you’re struggling than when you’re winning a lot of games,’’ Sveum said. “There’s no question about that.’’

First-time managers often are in the situation Sveum found himself in last season, part of a new hierarchy that cleans house in an attempt to resurrect the franchise.

Matheny’s case was different because he took over a winning team from Tony La Russa, who retired. He also had been part of the Cardinals’ organization, first as a player and since 2008 as a special assistant in the team’s player-development department.

“Mike knew the organization,’’ said La Russa, who talked about the Cardinals’ uninterrupted success during an appearance last month with the White Sox. “Even if I was gone or [Albert] Pujols [who left as a free agent], the Cardinals have a tradition. Mike’s been a part of that.’’

Matheny also was groomed as La Russa’s successor.

“Tony knew he would be retiring, and he talked to Mike a lot during the season,’’ one longtime Cardinals observer said.

Despite the departure of Pujols and the loss of starter Chris Carpenter to shoulder and neck injuries, the Cardinals’ machine continued to roll under Matheny, reaching the postseason.

Sveum was part of Theo Epstein’s team with no ties to Chicago or to the Cubs. He was given a patchwork squad with pitching problems and parts waiting to be traded at midseason. The second half of 2012 was as terrible as it could get, with a rotation working on shuttle service between the waiver wires and the minors, leading to 101 losses.

But players say Sveum’s demeanor helped the team get through it all.