user2306: What order does Bitcoin core place the inputs it spends in? Is it random? Is it sorted by anything? What, if anything, can you tell about the originator of a transaction by the input ordering?

user3697: The inputs are chosen by the function SelectCoins() in CreateTransaction() and then added one by one (without shuffling) to the transaction.
The order is defined by the coin selection (CWallet::SelectCoinsMinConf) which does a random shuffle of the potential useful inputs and a stochastic approximation.
Mind also that Bitcoin-Core's coin selection could be improved and there are several issues and improve proposals ([1], [2], [3])

2306: <p>What order does Bitcoin core place the inputs it spends in? Is it random? Is it sorted by anything? What, if anything, can you tell about the originator of a transaction by the input ordering?</p>
 3697: <p>The inputs are chosen by the function <code>SelectCoins()</code> in <a href="https://github.com/bitcoin/bitcoin/blob/0.11/src/wallet/wallet.cpp#L1801" rel="nofollow"><code>CreateTransaction()</code></a> and then <a href="https://github.com/bitcoin/bitcoin/blob/0.11/src/wallet/wallet.cpp#L1899" rel="nofollow">added one by one (without shuffling)</a> to the transaction.</p>

<p>The order is defined by the coin selection (<code>CWallet::SelectCoinsMinConf</code>) which does a random shuffle of the potential useful inputs and a stochastic approximation.</p>

<p>Mind also that Bitcoin-Core's coin selection could be improved and there are several issues and improve proposals (<a href="https://github.com/bitcoin/bitcoin/pull/4906" rel="nofollow">[1]</a>, <a href="https://github.com/bitcoin/bitcoin/issues/1643" rel="nofollow">[2]</a>, <a href="https://github.com/bitcoin/bitcoin/issues/3631" rel="nofollow">[3]</a>)</p>
