public class myTunes
{
public SimpleRecord[] tunes = new SimpleRecord[6];

public myTunes()
   {
   for( int x=0; x<tunes.length; x++ )
      {
      tunes[x] = new SimpleRecord("", "");
      }
   tunes[0].Artist = "Eric Clapton";
   tunes[0].Song = "Layla";

   tunes[1].Artist = "Every Time I Die";
   tunes[1].Song = "Kill The Music";

   tunes[2].Artist = "Boston";
   tunes[2].Song = "More Than A Feeling";

   tunes[3].Artist = "Journey";
   tunes[3].Song = "Don't Stop Believin'";

   tunes[4].Artist = "Queen";
   tunes[4].Song = "Killer Queen";

   tunes[5].Artist = "Lady Gaga";
   tunes[5].Song = "some crappy song";

   printDb();


   sortByArtist();
   printDb();
/*
   sortBySong();
   printDb();
*/
   }
	
	
// This method is complicated.
// It traverses the Artist list (using y)
// and for every y, it looks at all the artists before it (using z).
// It uses the String.compareTo() library method to get an indication
// how far the Artists are alphabetically from each other.
// It swaps the ones with a negative compareTo result.
public void sortByArtist()
   {
   int place;
   String temp;
   SimpleRecord tempRecord;
   for (int y=0; y<tunes.length; y++)
      {
      for (int z=0; z<y; z++)
         {
         place = tunes[y].Artist.compareTo( tunes[z].Artist ); 
         if (place < 0)
            {
            tempRecord = tunes[y];
            tunes[y] = tunes[z];
            tunes[z] = tempRecord;
            } // end if
         } // end for z
      } // end for y
   } // end method sortByArtist

public void sortBySong()
   {
   int place;
   SimpleRecord tempRecord;;
   for (int y=0; y<tunes.length; y++)
      {
      for (int z=0; z<y; z++)
         {
         place = tunes[y].Song.compareTo( tunes[z].Song ); 
         if (place < 0)
            {
            tempRecord = tunes[y];
            tunes[y] = tunes[z];
            tunes[z] = tempRecord;
            } // end if
         } // end for z
      } // end for y
   } // end method sortByArtist



public void printDb()
   {
   System.out.println( "----------------------------------"); 
   for (int a=0; a<tunes.length; a++)
      {
      System.out.println( tunes[a].Artist + " : " + tunes[a].Song );
      } // end for
   System.out.println( "----------------------------------"); 
   } // end printDb

public static void main(String args [])
   {
   new myTunes();
   } // end main
} // end class