Ethereum Classic
$4.67 -2.10%
ETC · 19w

universalSortingMechanism.sol - Universal Sorting Mechanism for Ethereum

struct RandomizationMechanism { mapping(uint => uint) sortingMechanism; uint totalSorted; bytes32 entropy; } RandomizationMechanism sortingTool[]; function sortingHat(uint _sortingType, uint _listSize) internal returns (uint) { RandomizationMechanism storage s = sortingTool[_sortingType]; s.totalSorted++; uint randomNumber = uint(sha3(block.blockhash(block.number-1), s.entropy, now)) % (_listSize - s.totalSorted); uint querySorter = s.totalSorted + randomNumber; // Instantiate sortingMechanism while people sort themselves if(s.sortingMechanism[querySorter] == 0) s.sortingMechanism[querySorter] = querySorter; if(sortingMechanism[totalSorted] == 0) s.sortingMechanism[s.totalSorted] = s.totalSorted; uint randomPosition = s.sortingMechanism[querySorter]; s.sortingMechanism[randomPosition] = s.sortingMechanism[s.totalSorted]; s.entropy = sha3(randomPosition, msg.sender, now); if(s.totalSorted == _listSize) s.totalSorted = 0; return randomPosition; }
Go to
Recent news
ETC -2.10% · · 12h

Kotti, Solidity, ETC, Oh My!

Kotti, the new Ethereum Classic Proof of Authority (PoA) test-network is out, so it was about time we took it for a little test drive. Kotti is part of the Goerli project for making PoA testnets on…
ETC -2.10% · · 18h

ETC Labs Presents: Ethernode

We’re building infrastructure software and hardware to transform the way people connect to and interact with Ethereum blockchains. The EtherNode is a robust piece of hardware designed to not only…