import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Collections;
public class MusicDatabaseII
{
static int x=0;
static String sname, aname, cdname;
static int time, track;

static SongComparator sc = new SongComparator();
static ArrayList myList = new ArrayList();
static MusicRecord  localCopy;

public static void main(String args [] )
{
File songList = new File("songs.txt");
try
   {
	BufferedReader arrayInput = new BufferedReader(  new FileReader( songList ) );
   while( arrayInput.ready() )
	   { 
      sname = arrayInput.readLine();
      aname = arrayInput.readLine();
      cdname = arrayInput.readLine(); 
      StringTokenizer tokenizer = new StringTokenizer(arrayInput.readLine());
      time = Integer.parseInt( tokenizer.nextToken() );
		track = Integer.parseInt( tokenizer.nextToken() );
		arrayInput.readLine(); // empty line
				
		localCopy = new MusicRecord( sname, aname, cdname, time, track );
		myList.add( localCopy );  

		} // end for
    arrayInput.close();
    } // end try
catch( IOException e)
    {
	 System.out.println("Bad File");
	 System.exit(0);
    }  // end catch 
	
Collections.sort( myList, sc );

for (x=0; x<myList.size(); x++)
   {  
   localCopy = (MusicRecord)myList.get(x);
   localCopy.printRecord();  
   } 
		 
} // end main
} // end class
