Sort Projects

Test tomorrow please help
Write a program to read in the data (can ask how many names) and print out the alphabetized data.
Sample data: Meus, Amistal, Kiefer,Bobo, Durrence, Byron, Taylor, Barry, Tilford, Butrimas, Bachelor.

Using
public static void selectionSort1(int[] x) {
for (int i=0; i<x.length-1; i++) {
for (int j=i+1; j<x.length; j++){
if (x[i] > x[j]){
//....Exchange elements
int temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}
}

[EDIT]

Disregard my post. Your code does do selection sort. It just does way more swaps than it should, but I'm guessing that doesn't matter much. I misread a part.

Anyway, that's not C++. Judging by the redundant "public static" and "int[]", I'd say it's java?
Last edited on
What's wrong with that? By the way use the code format. <>
Topic archived. No new replies allowed.