I am not sure it matters to produce a correctly formatted transaction, but I am playing around with a wallet that does not keep its own private keys, but produces the raw txs to sign and want to give the user the ability to verify the details of the raw txs with a third party or some control libraries. Assume, Bitcoin Core sets the standard, but I am unfortunately C illiterate. Thanks, Kyle
The two preceding answers describe correctly that there is no network-wide requirement to order inputs or outputs, but I don't agree that the "order doesn't matter".
Early on, many wallets did order their inputs and outputs, e.g. the inputs were in the order the addresses were created, in the order that they got picked by the wallet's coin selection, or simply sorted by age. Similarly, outputs would often list the recipient outputs first and the change output last. Such patterns are a privacy leak as they fingerprint the used wallet software, and may allow observers to learn additional data about the user's finances.
If everyone shuffled the inputs and outputs of a transaction properly these issues would be mitigated. However, it can be difficult to recognize whether an order is random or follows a more complex pattern. From what I understand, this is why BIP69 instead suggests a global adoption of sorting inputs and outputs lexicographically. Again, everyone would be indistinguishable if they all sorted the same way, and it would be much easier to audit, test, and notice wallets that don't adhere to such a standard.
The convention is to have the outputs in random order. This is specifically done in an effort to conceal which output is the change output. The change is by default sent to a new address that is owned by the sender, and as such has no history associated with it.
The majority of bitcoin's code is actually c++. Here is a link to the relevant transaction creation code, maybe there are a few comments that could point you in the right direction.