Created
October 24, 2016 21:20
-
-
Save seanavery/816fb589b9e7a1b8e663eaaf0797009f to your computer and use it in GitHub Desktop.
sorting algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function submitBid(uint _price, uint _amount) bidInMarket(_price) external returns (bool) { | |
Bid memory b; | |
b.price = _price; | |
b.amount = _amount; | |
for(uint i = 0; i < Bids.length; i++) { | |
if(Bids[i].price > _price) { | |
Bid[] memory tempBids = new Bid[](Bids.length - i); | |
for(uint j = i; j < Bids.length; j++) { | |
tempBids[j-i] = Bids[j]; | |
} | |
Bids[i] = b; | |
Bids.length = Bids.length + 1; | |
for(uint k = 0; k < tempBids.length; k++) { | |
Bids[i+k+1] = tempBids[k]; | |
} | |
return true; | |
} | |
} | |
Bids.push(b); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment