I don't quite understand your problem. Are you saying that you've a Reverse class that has an instance variable which is a 2D array? The first column holding String values & the second columns holding Integer object values?
I relize that and I am very thankfull, but I get errors when trying to do it that way. e.g I cannot use the Arrays.sort() method
posted 14 years ago
Sorry I will be more clear;
I am using the idea of a class that extends the Comparison class, I am using this as an array, I am attempting to sort it from another class, I am getting a NullPointerException on the following method;
Which is located in the reverse class, you have helped me out beyond what I could have hoped for guy's, if I can just get past the last road-block I will be extermly greatful and happy for your help.
Your above method has a possible source for the NullPointerException that you get. What happens if the parameter o is not actually an object of type Reverse, for some reason? The cast (Reverse)o will return null and attempting to call a method on this null reference will cause a NullPointerException! Of course, if this happens, there's probably a problem somewhere else in your program. Perhaps you can do something like
I'm not saying this will fix all of your problems. However, it will eliminate this particular source of an error, and even alert you later if you modify something that causes this.
My apologise, I didn't read the posts carefully enough.
My suggestion would be to use Collections.sort(List l, Comparator c). If you're using an Object to store your Reverse objects, you need to know the size before hand. But using List, you can have dynamic sizes.
Then by implementing the Comparator class, you can specify the sort order you need.