joseleonweb

Untitled

Jan 26th, 2021
575
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static void selectionSort(int[] numbers) {
  2.     int indexMin = 0; //the index of the smallest number
  3.     for(int i = 0; i< numbers.length; i++){
  4.         indexMin = i;
  5.         for(int j = i + 1; j < numbers.length; j++){
  6.             if(numbers[j] < numbers[indexMin]){//if we find a smaller int,
  7.                 indexMin = j; //set it as the min
  8.             }//endif
  9.         }//endfor
  10.         //we have the index of the smallest int and can swap the values
  11.         int temp = numbers[i]; //use temp to store the value
  12.         numbers[i] = numbers[indexMin];
  13.         numbers[indexMin] = temp;
  14.     }//endfor
  15. }//end method selectionSort
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×