Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] sort(int[] arr){
- int min, minIndex, temp;
- // 'start' is the point where 'unsorted' array begins
- for(int start = 0; start < arr.length - 1; start++){
- // Finding the minimum
- min = arr[start];
- minIndex = start;
- for(int i = start + 1; i < arr.length; i++){
- if(arr[i] < min){
- min = arr[i];
- minIndex = i;
- }
- }
- // Swap the minimum with the first element
- temp = min;
- arr[minIndex] = arr[start];
- arr[start] = temp;
- }
- return arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement