Stock sale & the IRS

If I bought 100 shares of company XYZ 6 months ago at $20 and another 100 shares 3 months ago at $10 and then today I sold 100 shares at $15. Does the IRS insist that I sold the first 100 shares or the more recently purchased 100 shares, or some average?

Not looking for financial advice just general info. Anyone reluctant to answer the question directly, could you point me to the relevant IRS publication or tell me what the appropriate search terms would be? I can’t figure out what to search on.

Thanks.

The default rule is first in, first out. So it would be the first 100.

But if you choose, you can specify particular lots to your broker at the time of sale, and then the cost of those particular shares is used. I assume they have to give this option since you could have physical stock certificates that really did have different costs, and you could choose to sell one or the other.