A good ankle sock has a bit of weight to it even before you put it on, a kind of density when you scrunch it in your hand, rather than the thin, slightly see through feel you get from the ones sold in packs of ten for almost nothing. You should be able to stretch the welt, that ribbed band at the top, and feel it spring back properly rather than stay loose and gaping. If it's already sagging on the cardboard packet, it will be around your ankle by lunchtime, no question.
In the shop, or clicking through online, I check three things without fail. First, the fibre content, because anything under about seventy per cent cotton tends to go thin and shiny at the heel within a couple of months, so I look for a decent cotton base with a small amount of nylon or elastane worked through, enough to hold shape without making the whole thing feel synthetic against the skin. Second, the heel and toe, because a reinforced heel in a slightly darker thread is a good sign someone thought about wear, not just appearance, and a flat toe seam matters more than people expect, a lumpy one will needle away at you through a whole day in trainers. Third, the actual depth of the ankle, since "ankle sock" covers everything from a sliver that sits under the anklebone to a proper two inch cuff, and you want to know which you're buying before six of them turn up and sit at completely different heights under the same boots. They wear in an unglamorous but predictable way. The first few washes soften the ribbing slightly, which is fine, that's just the fibres settling, but after that any further softening or thinning is a sign the pair is on its way out. Washing them inside a mesh bag stops them pairing off with someone else's laundry forever, and keeping them out of the tumble dryer, or at least off a hot setting, adds real months to the elastane doing its job at the top, because heat is what kills that spring, not the washing itself.
If you're starting from nothing, or replacing a drawer full of mismatched survivors, go for a plain cotton rich pair in a mid cuff height, nothing too skimpy, nothing that climbs halfway up the shin. It's the version that works under boots, trainers and flat shoes without you having to think about it, which is really all you want from a sock.
Buy a few more pairs than feels necessary, in the same style, so you're never hunting for the other half of a match at seven in the morning.
I'd also check out knee high socks.