Created
November 2, 2013 16:37
-
-
Save Scuilion/7280836 to your computer and use it in GitHub Desktop.
This file contains 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
def list = [-100,3,4,2,5,6,7,-2,0] | |
def sorted =[list[0]] | |
long startTime = System.currentTimeMillis(); | |
for(int i=1; i < list.size; i++){ | |
def insert = list[i] | |
for(int j=sorted.size-1; j>=0; j--){ | |
if(insert > sorted[j]){ | |
sorted.addAll(j+1,insert) | |
break; | |
} | |
if(j==0){ | |
sorted.addAll(0,insert) | |
} | |
} | |
} | |
println sorted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment