Problems with ClassCastException

I have a program that has an array of Strings instantiated as follws; String decisions[][] =new String[50][2];

and I need to sort the array. I was trying to use Arrays.sort(decisions); but it throws a ClassCastException and the program hangs. Is there anyway to use the built in sort function of the Arrays class for an array of Strings without gettign this error?

[412 byte] By [pocniba] at [2007-10-2 12:18:01]
# 1

Please refer to javadoc on java.util.Arrays.sort(Object[] a). It says:

Sorts the specified array of objects into ascending order, according to the natural ordering of its elements. All elements in the array must implement the Comparable interface. Furthermore, all elements in the array must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the array).

When you sort String[][] each element becomes String[] -- which does not implement Comparable interface and so sort() methods throws ClassCastException as specified. I am not sure what do you mean when you say "it hangs" -- does your java program hangs or just shows exception stack trace and exits?

sundararajan.aa at 2007-7-13 9:05:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
I just catch the error so I knew there was a ClassCastException in the code. Is there a built in sort function for 2 Dimensional Arrays or is a custom sort needed?
pocniba at 2007-7-13 9:05:15 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...