Sort the character arrays insensitive in java

understand the code and write that yourself, you’ll learn better

May be its bad practice a but i think the dummy way will be.

  1. Create 2 new array 1 to store index of characters in actual array and other for converted upercase or Lower case array.
  2. sort the converted array along with the index relocation
  3. and then use index to create sorted result of old array

@techbuzz nice approach!!

As you are looking for a case insensitive sort, it is like a custom sort where you can use a Comparator.
You need to convert the String to char[].
Pass it to Arrays.sort(array,comparator);
Please check if this works.

Here is the code
public class ArrayCheck {

public static void main(String[] args) {
	String str="World";
	char[] charArray = str.toCharArray();
	Character[] temp=new Character[charArray.length];
	for(int pos=0;pos<charArray.length;pos++){
	CaseInsesitive caseI=new CaseInsesitive();

class CaseInsesitive implements Comparator{

public int compare(Character o1, Character o2) {
	return String.valueOf(o1).toLowerCase().compareTo(String.valueOf(02).toLowerCase());