Hey all
I'm busy writing a program - as stated in an earlier post of mine - to keep a database of songs and then allow them to be listed, sorted alphabetically by track artist etc...
here are the variables:
songDis[100][4] //nested array, 100 songs, 4 properties for each
temp[] //array to temporarily store the songDis array, while swapping around
songNum //the amount of songs
sortBy //can be 0, 1, 2 or 3 to signify whether to sort by track artist etc
Here's the part to alphabetize:
for (int a = 1; a < songNum; a++)//alphabetizing songs {
for (int b = a + 1; b < songNum + 1; b++) {
if (song[a][sortBy].compareTo(song[b][sortBy]) > 0) {
temp = songDis[a];
songDis[a] = songDis[b];
songDis[b] = temp;
}
}//for b
}//for a
It seems to work. But it sometimes just throws up completely random songs ordering...