Optimized way to get a JList sorted in 2 groups?

Put the users in an ArrayList and use the built-in Java sort functionality: download.oracle.com/javase/6/docs/api/ja....

Put the users in an ArrayList and use the built-in Java sort functionality: download.oracle.com/javase/6/docs/api/ja... This will invoke a mergesort, which will be more efficient than what you've written. What exactly are you trying to do in the first for loop? As far as I can see, you only need to do the following: Loop once over all users, throwing all "1st" users in ArrayList A, all "2nd" users in ArrayList B Sort A, Sort B, Merge A and B back together.

When I use Collections. Sort(us) it shows following error: Bound mismatch: The generic method sort(List) of type Collections is not applicable for the arguments (List). The inferred type User is not a valid substitute for the bounded parameter > – Harry Joy May 25 at 12:57 Implement the Comparable interface for your user Objects.

– Jeroen Baert May 25 at 14:46 +1 for Comparable; a more recent link might be in order. – trashgod May 25 at 18:59.

As noted by @Jeroen, implementing Comparable is the preferred approach. You can also implement Comparator as shown in RecordComparator or use SortedComboBoxModel.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions