• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arrays Sorting

 
Abhi vijay
Ranch Hand
Posts: 509
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1951
7
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Punit Singh
Ranch Hand
Posts: 952
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see it is not "done", it is " done" mean space than done.
 
Abhi vijay
Ranch Hand
Posts: 509
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.thanks.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic