Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sorting

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I need to Sort the String which is like "200036.9116.2.5.1.16.1613454297". which have the number separated by the period(.).


And its Unique. Please give me some ideas..
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it mean to sort a string? What would this particular string look like after "sorting"?

You can obtain a list of all substrings using a String.split("\\.") method call.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12122
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you want to take a single string, break out the parts, and sort those?

or will you have dozens of strings like this, and you want to sort all of those based on various fields within the string?

and what do you mean by "it's unique"?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic