aspose 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
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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

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