Skip to content

Instantly share code, notes, and snippets.

@mattmccarthy11
Created November 4, 2015 03:59
Show Gist options
  • Save mattmccarthy11/1ac0db84f0e5f6f4a751 to your computer and use it in GitHub Desktop.
Save mattmccarthy11/1ac0db84f0e5f6f4a751 to your computer and use it in GitHub Desktop.
Sort Arrays
String[] mystr = {"Jack","Fortran","Amon","Cpp","Phaser"};
for(int i=0;i<mystr.length-1;i++){
for(int j=i+1 ;j<mystr.length;j++){
if( mystr[i].compareTo(mystr[j]) > 0 ){
String tmp = mystr[i];
mystr[i]= mystr[j];
mystr[j]=tmp;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment