Is there a way to sort a single String containing multiple data types?
example:
//a string containing int and words(strings)
String str1 = “1 one 2 two t”;
String str2 = “1 two 3 two t”;
String str3 = “1 three 1 two t”;
let’s say I wanted to sort it JUST by the 2nd int within those three strings.
Is there a way to tell java to search a just particular part of a String?
so the output that I want would be be list like:
str3
str1
str2
or
"1 three 1 two t"
"1 two 2 two t"
"1 one 3 two t"
What do you mean by sorting a single
String? You should split out the string into whatever groupings you want to sort on, and then sort that. If your data has a particular format, you should write a short, simpleclasscontaining the elements split out into appropriate fields.