Sorting Two Classes

Hi everyone! I am brand new to Java and before I pull the remainder of my hair out, I thought I'd come here and see if anyone one could give me some advice.

I am trying to make a sort program. It needs to sort by title and by item number. I can make it sort by title, but have tried adding sorting by item number to no avail. I just don't know how to sort two classes or how to add the item numbers to sorted seperately. Here's the code I have so far:

//Date: August, 2003
//Program: Video Invoice
//A program that sorts videos by title and number.

public class Videos
public static void main(String[] args)
String[] videos =
{"American Pie", "Kangaroo Jack", "The Ring", "Beauty and the Beast", "Something About Mary"};
int x;

System.out.println("Before sort:
for (x = 0; x < 5; ++x)
sortStrings(videos, videos.length);
After sort:
for(x = 0; x < 5; ++x)

public static void sortStrings(String[] array, int len)
int a,b;
String temp;
int highSubscript = len - 1;
for(a = 0; a < highSubscript; ++a)
for(b = 0; b < highSubscript; ++b)
if(array.compareTo(array[b + 1]) > 0)
temp = array;
array = array [b + 1];
array[b + 1] = temp;


Any advice?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!