hi!
is there anyone else who can correct my codes?
i know this is wrong
here's the problem: Write a class called slectionSort
this would allow the user to input ten string names (e.g adal, bryan, pius,apple, mango,strawberry, zion, mary, thalea, bon.. . ) and will sort to ascending order using the SelectionSort
the output will be:
adal
apple
bon
bryan
mary
pius
strawberry
thalea
zion
and here is my disusting codes
i can't get it.. maybe its because i use the String.. please help me
public class selectSort{ public static void main(String a[]){ int i; String array[] = {. . .}; System.out.println("Data items in original order "); for(i = 0; i < array.length; i++) System.out.print( array[i]+" "); System.out.println(); selection_srt(array, array.length); System.out.println("Data items in ascending order"); for(i = 0; i <array.length; i++) System.out.print(array[i]+" "); } public static void selection_srt(String array[], int n){ for(int x=0; x<n; x++){ int min = x; for(int y=x; y<n; y++){ if(array[min]> array[y]){ min = y; } } String temp = array[x]; array[x] = array[min]; array[min] = temp; } } }