Partial backport of core#28970:
https://github.com/bitcoin/bitcoin/pull/28970/commits/092c978a42e8f4a02291b994713505ba8aac8b28
TxId sorting is correct, see D1527 (and comment in the test).
Since we use txid instead of wtxid + correct endianness in the comparison, the test is greatly simplified.
Note that we miss some backports that would allow to remove the type and version from the hasher/datastream, but there is no difference in behavior.
Depends on D16490.