File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Arrays Sorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Arrays Sorting" Watch "Arrays Sorting" New topic
Author

Arrays Sorting

Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509


If a comparator is not used for sorting, the answer is done,aone,bone,cone.??? What is happening. Shouldnt it sort by its natural order?
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1763
    
    7

It is being sorted according to java.lang.String's natural order. Look carefully at the String " done".
What's that whitespace doing there? What do you suppose the lexicographical order of that character is?

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
see it is not "done", it is " done" mean space than done.


SCJP 6
Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509
Ok.thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays Sorting