Sorting
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Suresh_Adina
Posted On:   Tuesday, May 22, 2001 12:02 AM

We need a method to sort String arrays in a specific way.

Test array = {"1", "2", "a", "b", "A", "B"}

Collections.sort gives the result:

A B a b 1 2

What we need is something like:

1 2 A a B b

This is just a simple test case. But that is the pattern of sorting required.
Can you help?

Re: Sorting

Posted By:   John_Zukowski  
Posted On:   Tuesday, May 22, 2001 04:04 PM

The interface is Comparable.... Just create one for the specific sort order you want and pass it to the appropriate Arrays method for sorting.

Re: Sorting

Posted By:   Ivo_Limmen  
Posted On:   Tuesday, May 22, 2001 12:17 AM

The collection framework uses the interface Comparible. If you really need a differend sorting algorithm you need to implement your own. Write a simple wrapper for the data that implement the Comparible method... and that's it.
About | Sitemap | Contact