Stocks are sort of like plants: Different plants grow best in different seasons. Likewise, different types of stocks perform better in different "seasons" of the market.

We're in a largely barren season right now, with the major market indexes in bear markets. However, certain types of stocks are flourishing. Here are the two best sectors to invest in right now.

1. Energy

Of the top 10 stocks with the biggest market caps that have soared 20% or more year to date, seven are energy stocks. It's much easier to find energy stocks that are in positive territory this year than to find those that aren't.

ExxonMobil (XOM 0.12%) ranks as the biggest energy stock of all, with a market cap of more than $350 billion. Its shares have skyrocketed close to 40% year to date, and were up as much as 71% earlier this month.

The second-biggest energy company, Chevron (CVX 0.50%), has also delivered impressive gains. Shares of the oil and gas giant are up more than 20%.

You don't have to be a rocket scientist to understand why these stocks and others in the energy sector are performing so well. Energy demand has increased significantly as the global economy emerges from the shadow of COVID-19, and Russia's invasion of Ukraine has disrupted the supply of oil and gas. A combination of higher demand and lower supply inevitably leads to higher prices.

But is it too late to buy energy stocks? Warren Buffett certainly doesn't think so. He just bought even more shares of Occidental Petroleum for Berkshire Hathaway's portfolio in recent days.

It's possible that fuel prices could come down somewhat over the near term. However, the European Union plans to ban most Russian oil imports by the end of this year. That could keep prices at high levels for a while -- and keep the energy sector as one of the best places for investors to park their money.

2. Healthcare

The other three of the 10 stocks with the biggest market caps that have soared 20% or more this year are all in the healthcare sector. To be sure, not every healthcare stock is performing well in 2022. However, the shares of several big drugmakers have taken off.

Vertex Pharmaceuticals (VRTX -0.94%) especially stands out. The big biotech stock has vaulted nearly 30% higher so far this year.

Bristol Myers Squibb (BMY -0.18%) isn't too far behind Vertex. Shares of the big biopharmaceutical company have jumped more than 25% year to date.

These and other big drug stocks have performed well overall, in part because some investors view them as safe havens. Physicians won't stop prescribing Vertex's and Bristol Myers Squibb's medicines just because inflation is high or interest rates are rising. Large drugmakers typically generate steady cash flow. Many of them also pay dividends (although Vertex doesn't).

Vertex and Bristol Myers Squibb have outgained their peers, though, due to their own unique catalysts. Both companies have benefited from positive clinical and regulatory developments this year.

For example, in March Vertex advanced VX-147 into late-stage testing for treating APOL1-mediated kidney disease. Earlier this month, the experimental drug won breakthrough therapy designation from the U.S. Food and Drug Administration (FDA) and priority medicines (PRIME) designation from the European Medicines Agency.

Bristol Myers Squibb has also had plenty of good news, including announcing positive late-stage results for mavacamten in February. The FDA approved the heart failure drug in April. Bristol Myers Squibb thinks mavacamten could generate peak annual sales of at least $4 billion.

Investors have to do their homework before buying healthcare stocks; some will be more susceptible to economic headwinds than others. However, big drugmakers with strong product lineups and promising pipelines should have a good chance of outperforming the market this year.