Sorting in Solidity without Comparison
This article discusses the cost of sorting small sets of numbers in Solidity, the defacto smart contract language for the Ethereum blockchain.
Background
During the development and testing of Datona Labs’ Solidity Smart-Data-Access-Contract (S-DAC) templates, we wanted to sort some small sets of small numbers, for example:
function sortHands(Hand[noPlayers] memory hands) internal pure {
for (uint player = 0…