• Post Reply Bookmark Topic Watch Topic
  • New Topic

Arrays Sorting  RSS feed

 
Ranch Hand
Posts: 509
  • 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?
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • 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?
 
Ranch Hand
Posts: 952
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.thanks.
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!