### Question:
DefaultCoinSelector implements CoinSelector { @VisibleForTesting static void sortOutputs(ArrayList<TransactionOutput> outputs) { Collections.sort(outputs, new Comparator<TransactionOutput>() { @Override public int compare(TransactionOutput a, TransactionOutput b) { int depth1 = 0; int depth2 = 0; TransactionConfidence conf1 = a.getParentTransaction().getConfidence(); TransactionConfidence conf2 = b.getParentTransaction().getConfidence(); if (conf1.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) depth1 = conf1.getDepthInBlocks(); if (conf2.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) depth2 = conf2.getDepthInBlocks(); Coin aValue = a.getValue(); Coin bValue = b.getValue(); BigInteger aCoinDepth = BigInteger.valueOf(aValue.value).multiply(BigInteger.valueOf(depth1)); BigInteger bCoinDepth = BigInteger.valueOf(bValue.value).multiply(BigInteger.valueOf(depth2)); int c1 = bCoinDepth.compareTo(aCoinDepth); if (c1 != 0) return c1; int c2 = bValue.compareTo(aValue); if (c2 != 0) return c2; BigInteger aHash = a.getParentTransaction().getHash().toBigInteger(); BigInteger bHash = b.getParentTransaction().getHash().toBigInteger(); return aHash.compareTo(bHash); } }); }  @Override CoinSelection select(Coin biTarget, List<TransactionOutput> candidates); static boolean isSelectable(Transaction tx);  }### Answer:
@Test public void coinAgeOrdering() throws Exception { Transaction t1 = checkNotNull(sendMoneyToWallet(COIN, AbstractBlockChain.NewBlockType.BEST_CHAIN)); wallet.notifyNewBestBlock(FakeTxBuilder.createFakeBlock(blockStore).storedBlock); final Coin TWO_COINS = COIN.multiply(2); Transaction t2 = checkNotNull(sendMoneyToWallet(TWO_COINS, AbstractBlockChain.NewBlockType.BEST_CHAIN)); Transaction t3 = checkNotNull(sendMoneyToWallet(CENT, AbstractBlockChain.NewBlockType.BEST_CHAIN)); ArrayList<TransactionOutput> candidates = new ArrayList<TransactionOutput>(); candidates.add(t3.getOutput(0)); candidates.add(t2.getOutput(0)); candidates.add(t1.getOutput(0)); DefaultCoinSelector.sortOutputs(candidates); assertEquals(t2.getOutput(0), candidates.get(0)); assertEquals(t1.getOutput(0), candidates.get(1)); assertEquals(t3.getOutput(0), candidates.get(2)); }