public int[][] reconstructQueue(int[][] people) {//(h, k)

int N = people.length;

int[][] aux = people.clone();

Arrays.sort(aux, new Comparator<int[]>() {

@Override

public int compare(int[] o1, int[] o2) {

if (o2[0] == o1[0]) return o1[1] - o2[1];

else return o2[0] - o1[0];

}

});

for (int i = 1; i < N; i++) {

int h = aux[i][0], k = aux[i][1];

for (int j = i; j > k; j--){

aux[j] = aux[j - 1];

}

aux[k] = new int[]{h, k};

}

return aux;

}