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?
ok I solved the vector list issue, just need to know about alphabetical order
http://stackoverflow.com/questions/708698/how-can-i-sort-a-list-alphabetically
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.
how about this: ``` Collections.sort(listToSort, String.CASE_INSENSITIVE_ORDER); ```
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.
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
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
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"
ye lol, you can do "ignore case" too, also very popular.
I'll make a note of that, thanks
Join our real-time social learning platform and learn together with your friends!