public static int[] calcSortOrder(IntArrayList arr1, IntArrayList arr2) {
        if (arr1.elementsCount != arr2.elementsCount) {
            throw new IllegalArgumentException("Arrays must have equal size");
        }
        return calcSortOrder(arr1.buffer, arr2.buffer, arr1.elementsCount);
    }
@Test
    public void testCalcSortOrder() {
        assertEquals(from(), from(ArrayUtil.calcSortOrder(from(), from())));
        assertEquals(from(0), from(ArrayUtil.calcSortOrder(from(3), from(4))));
        assertEquals(from(0, 2, 3, 1), from(ArrayUtil.calcSortOrder(from(3, 6, 3, 4), from(0, -1, 2, -6))));
        assertEquals(from(2, 3, 1, 0), from(ArrayUtil.calcSortOrder(from(3, 3, 0, 0), from(0, -1, 1, 2))));
        assertEquals(from(), from(ArrayUtil.calcSortOrder(new int[]{3, 3, 0, 0}, new int[]{0, -1, 1, 2}, 0)));
        assertEquals(from(0), from(ArrayUtil.calcSortOrder(new int[]{3, 3, 0, 0}, new int[]{0, -1, 1, 2}, 1)));
        assertEquals(from(1, 0), from(ArrayUtil.calcSortOrder(new int[]{3, 3, 0, 0}, new int[]{0, -1, 1, 2}, 2)));
        assertEquals(from(2, 1, 0), from(ArrayUtil.calcSortOrder(new int[]{3, 3, 0, 0}, new int[]{0, -1, 1, 2}, 3)));
        assertEquals(from(2, 3, 1, 0), from(ArrayUtil.calcSortOrder(new int[]{3, 3, 0, 0}, new int[]{0, -1, 1, 2}, 4)));
    }