Thread: Alphabetizing
View Single Post
  #1 (permalink)  
Old 11-06-2007, 06:13 PM
carderne carderne is offline
Member
 
Join Date: Nov 2007
Posts: 97
carderne is on a distinguished road
Alphabetizing
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:
Code:
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:

Code:
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...
Reply With Quote
Sponsored Links