short term losses offset short term gains
long term losses offset long term gains
if one type is net gain and the other net losses they are netted.
if the net is a gain (loss) the type depends on the type that had more gains (loses) than the other type
if both types are losses, short term is used first.
why not just print out schedule d and follow the line instructions to see how it works.
https://www.irs.gov/pub/irs-pdf/f1040sd.pdf