Skip to content

Instantly share code, notes, and snippets.

View hbksagar's full-sized avatar

Krupa Sagar hbksagar

View GitHub Profile
@hbksagar
hbksagar / InsertionSort.sol
Last active May 7, 2021 12:43
Solidity Insertion sort for sorting less than 10 items with reference
pragma solidity ^0.8.0;
contract InsertionSort{
function sort(uint256[] memory data, uint256[] memory refs) internal pure returns (uint256[] memory, uint256[] memory){
// Higher deployment cost but betters execution cost
int256 j;
uint256 unsignedJ;
uint256 unsignedJplus1;
uint256 key;
uint256 val;