Ethereum Classic
$7.70 0.43%
ETC · 1w

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 gist.github.com
Recent news
ETC +0.43% · twitter.com · 14h

My goal is to speedup program processing on ETC. The Just in Time (JIT) compiler we are working on will decrease execution time of smart contracts running in SputnikVM. It's possible we may accelerate execution by 30x to 60x." ~ Michael Collison - Compiler Engineer - ETCDEV

"My goal is to speedup program processing on ETC. The Just in Time (JIT) compiler we are working on will decrease execution time of smart contracts running in SputnikVM. It's possible we may accelerat...