Skip to content

Instantly share code, notes, and snippets.

@Scuilion
Created November 2, 2013 16:37
Show Gist options
  • Save Scuilion/7280836 to your computer and use it in GitHub Desktop.
Save Scuilion/7280836 to your computer and use it in GitHub Desktop.
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