Last active
August 29, 2015 14:14
-
-
Save cwade12c/bc27971d3c9c5b88cfa7 to your computer and use it in GitHub Desktop.
sort and search utilities
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
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