File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes ArrayList sorting using comparator performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "ArrayList sorting using comparator performance" Watch "ArrayList sorting using comparator performance" New topic
Author

ArrayList sorting using comparator performance

Rahul Nair
Ranch Hand

Joined: Dec 01, 2007
Posts: 138

Hello Ranchers,

I have doubt about the sorting performance when using comparator.
Please consider the following code:

and

Which code is preferable if we compare the performance and why ?


Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

Rahul,
What happened when you tried it by running against a large list?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Rahul Nair
Ranch Hand

Joined: Dec 01, 2007
Posts: 138

Hi Jeanne,

I have not tried for large number of list. However my understanding is that the first code should be the choice ? Isn't it ?

Thanks,

Rahul
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

I have no idea. If I wanted to know, I'd try it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList sorting using comparator performance
 
Similar Threads
Collections
Sorting
Hibernate sorting issue
Sorting an ArrayList<MyObject> by a member of said MyObject
Hey guys, A little help with binary trees