Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class Sort_Search {
- public static void main(String[] args) {
- int[] myArray = {15,10,17,1,5,20,25};
- printArray(myArray);
- System.out.println();
- sortArray(myArray);
- printArray(myArray);
- }
- public static void printArray(int[] arr)
- {
- for(int value: arr)
- {
- System.out.print(value + " ");
- }
- }
- public static void sortArray(int[] arr)
- {
- for (int i = 0; i < arr.length;i++)
- {
- int low = i;
- for (int j = i+1; j < arr.length; j++)
- {
- if (arr[j] < arr[low])
- {
- low = j;
- }
- }
- int temp = arr[low];
- arr[low] = arr[i];
- arr[i] = temp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement