For many investors, 2022 has been a less than ideal year in the stock market, to put it lightly. Unfortunately, there's no guarantee that 2023 will be any better.

While investors can't control the market, they should focus on what they can control, and that's investing in a diverse collection of sound stocks with solid track records and long-term potential. If you have $10,000 to invest, here are two great stocks to buy right now.

Vanguard Total Stock Market ETF

One of the key pillars of investing is diversification. "Don't put all your eggs in one basket" holds true in many aspects of life, but especially when putting your money in the stock market. One way to have a diversified portfolio is by investing through index funds, which combine numerous stocks into one investment vehicle. One great option for investors is the Vanguard Total Stock Market Index Fund ETF (VTI -0.47%).

Two people smiling and counting money at a table.

Image source: Getty Images.

The Vanguard Total Stock Market ETF is a one-stop shop for diversification. Designed to give investors exposure to the entire U.S. stock market, this fund contains large-cap, mid-cap, and small-cap growth and value stocks. It also has the benefits of containing blue-chip stocks and lessening your investing risk. All three of these are especially important during times of economic uncertainty.

No one can predict with certainty how individual companies will perform. But with a fund that covers as much ground as this one, you can be certain that results will closely track the overall market over the long term. It's down over 18% year to date, but that shouldn't deter investors. Including 2022, the fund has finished in the negative five times since its inception in 2001, but the long-term results are there.

It's not a flashy choice, but it's an effective ETF that investors with time on their side would be smart to choose.

Walmart

Bringing in $152.8 billion in revenue in just the third quarter of its 2023 fiscal year (up 8.7% year over year), Walmart (WMT 0.57%) is a cash cow. The retail giant is also one of the few blue-chip companies that has seen its stock price in the green this year.

Walmart's "Save Money. Live Better" motto accurately describes why it's a great buy for 2023 and beyond. With inflation at levels not seen in 40 years and a recession that seems very likely to happen, Walmart will reap the benefits of consumers becoming more price-conscious. The company has even said it's started seeing higher-earning people gravitating toward its stores to offset higher prices.

What sticks out with Walmart is the success of its grocery segment. With food prices up 10.9% from this time last year, the company has benefited and increased its market share in groceries. They account for more than half of Walmart's sales. The shift from customers buying general merchandise to groceries has lowered Walmart's gross profit rate a bit, but the growing market share is a good sign.

Spread out your $10,000

With the amount of uncertainty in the stock market right now, one of the best things investors can do is to use a strategy of dollar-cost averaging. When you dollar-cost average, you invest a set dollar amount at regularly scheduled intervals, as opposed to irregularly making large lump-sum investments. In this case, you could evenly divide the $10,000 between Walmart and the Vanguard Total Stock Market Index Fund ETF and choose an investing schedule you're comfortable with--say, $1000 on the first of every month for the next ten months.

Your investing schedule doesn't have to be monthly, though. It could be every other day, weekly, bi-weekly, or whatever works for you. The most important thing is to stick to your schedule, regardless of what the stock prices are at the time. Dollar-cost averaging helps avoid a situation in which you invest a lump sum right before a market drop.