public static void sort(int[] arr, int k){
        Comparator<Integer> comparator = new Comparator<Integer>(){
            public int compare(Integer n1, Integer n2){
                return n1 - n2;
            }
        };

        PriorityQueue<Integer> queue = new PriorityQueue<Integer>(k + 1, comparator);
        for(int i = 0; i < k + 1; i++){
            queue.offer(arr[i]);
        }

        int index = 0;
        int i = k + 1;
        while(i < arr.length){
            arr[index] = queue.poll();
            queue.offer(arr[i]);
            index++;
            i++;
        }

        while(index < arr.length){
            arr[index] = queue.poll();
            index++;
        }
    }