public void sortWithNoDuplicates(char[] mas){
    	sorted = mas;
        duplicates = new char[mas.length];
        int counterForDuplicates = 0;
        end = mas.length - 1;


        for(int i = 0; i < end; i++){
            char value = mas[i]; //temp ceil for comparing(selection sort)
            int minI = i; //temp index for comparing(selection sort)

            for(int j = i + 1; j <= end; j++){
                if(mas[j] < value){
                    minI = j; 
                    value = mas[j];
                } else if(mas[j] == value){ // condition for duplicates 
                    duplicates[counterForDuplicates++] = mas[j]; // put into mas for duplicates
                    swap(mas, j, end--);//duplicate go to end position, end limit will decrease
                }
            }

            swap(mas, i, minI);
        }
        
        trimToSize();

    }