Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (javk):

1- I want to arrange a list alphabetically in java. does that mean I have to write the method as opposed to using Collections.sort();? How can I print a vector list?

OpenStudy (javk):

ok I solved the vector list issue, just need to know about alphabetical order

OpenStudy (javk):

yeah, I tried that...and it works but the thing is that in their example they are using country name's i.e. they all start with capital letters. In my case I have both upper and lowercase letters. now, I have a solution to that, convert all of the uppercase letters to lower case using ` .toLowerCase `, and that works too. The issue at this point is that in order to do that, I had to convert the vector list into a string (That worked just fine), but now that it's turned into a string, ` Collections.sort ` won't work. So I cast the string into an ArrayList (and that worked fine too), but neither ` Collections.sort ` nor ` Arrays.sort ` is working.

OpenStudy (anonymous):

how about this: ``` Collections.sort(listToSort, String.CASE_INSENSITIVE_ORDER); ```

OpenStudy (javk):

your a GENIUS. I was so sure something like this existed, and yet I could never get my hands on it. Thanks...it works superbly.

OpenStudy (anonymous):

I'm not java expert, I also assumed such thing exists so I googled =) https://www.google.co.il/search?q=java+order+alphabetically+case+insensitive

OpenStudy (anonymous):

First result, top rated answer (second one) is exactly that =) The first answer shows you that you can make your own comperator for any case, but for this specific case there is a built in one in java

OpenStudy (javk):

I've been googling it for quite some time now and never came across it, buy it seems I didn't use the magic words "case-insensitive"

OpenStudy (anonymous):

ye lol, you can do "ignore case" too, also very popular.

OpenStudy (javk):

I'll make a note of that, thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!