Sort the character arrays insensitive in java

Please tell me - How sort character array case insensitive?

input: World

Output: dlorW

Any constraints? Which complexity algo you want? O(N^2)? O(NlogN)?

No constraints.

Algorithm is as follows:

  1. extract all lowercase and uppercase letters into different string

  2. sort each string differently

  3. append the sorted string

  4. display the result

  5. If you need code, comment

By Append, do you mean adding at end or mixing them? Because I feel that for a string “bAdC” he wants it as “AbCd”. Meaning alphabets sorted irrespective of case.

does he want bdAC or as you stated, AbCd? He doesn’t explain that. :
If it is like yours I can use the concept of merge sort while appending sorted strings. Yup appendingg means adding at the end.

I feel he wanted AbCd. I think you should also provide that solution (who knows, might help some1 else XD)

is it possible to use sort function?

yup u can use sort function

1 Like

One Thing you can do is to either convert all the uppercase to lower case or vice versa and mark them to be changed later.

After doing the above operation just sort the string as usual.

After sorting, traverse the string and convert all those characters stored in temporary vector say mv to be changed later to Uppercase. (Considering you had earlier converted uppercase to lowercase )

Print Your result.

SEE IMPELMENTATION OF CODE

http://ideone.com/10W8TD it is the link to the way vijju stated

check my implementation it is simpler!

@neilit1992 Were you using MergeSort. I don’t find it easy.

I wasn’t using merge sort though it can be solved using merge sort, check the code probably you’ll get it. I just modified the sort function.

I cant find your code ? :expressionless:

Can you check it in ideone.com

check the link i commented

Lol. 8 seconds difference b/w you giving link and him asking later.

1 Like

Please write code in java.

//