Skip to content

Instantly share code, notes, and snippets.

@cwade12c
Last active August 29, 2015 14:14
Show Gist options
  • Save cwade12c/bc27971d3c9c5b88cfa7 to your computer and use it in GitHub Desktop.
Save cwade12c/bc27971d3c9c5b88cfa7 to your computer and use it in GitHub Desktop.
sort and search utilities
public static void sortArray(int[] arr)
{
int currentPos, startPos, smallest;
int tmp;
for( startPos = 0; startPos < arr.length - 1; startPos++ )
{
smallest = startPos;
for( currentPos = startPos + 1; currentPos < arr.length; currentPos++ )
{
if( arr[smallest] > arr[currentPos] )
{
smallest = currentPos;
}
}
tmp = arr[startPos];
arr[startPos] = arr[smallest];
arr[smallest] = tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment