Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList sorting using comparator performance

 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul,
What happened when you tried it by running against a large list?
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea. If I wanted to know, I'd try it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic