I'm currently trying to make a mini dictionary. To do it i need to learn how to sort strings in alphabetical order. Can anyone tell me or give me a hint as to how am i going to sort the words in alphabetical order.
eyndyel 0
Newbie Poster
Recommended Answers
Jump to PostThe String method compareToIgnoreCase should do the trick. For example:
int result = string1.compareToIgnoreCase(string2); // here result < 0 if string1 > string2 // or result = 0 if string1 == string2 // or result > 0 if string1 < string2
That should give you a start …
Jump to Post> Can anyone tell me or give me a hint as to how am i going to sort the words
> in alphabetical order.Look into the Collections#sort method which takes a
Comparator
instance to facilitate custom sorting.
All 6 Replies
darkagn 315
Veteran Poster Featured Poster
~s.o.s~ 2,560
Failure as a human Team Colleague Featured Poster
BestJewSinceJC 700
Posting Maven
darkagn 315
Veteran Poster Featured Poster
heenas 0
Newbie Poster
jon.kiparsky 326
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.