Want a Free Job Posting?

Buy a job posting today and the second one is on us. For a limited time only. Act Now.

Interview Question

Interview New York, NY

Nothing too unexpected. It seems like "sort a list based on

  the order of another list" is a very popular question there.

Interview Answer

1 Answer


public static void foo(){ // Sort data based on order final int[] data=new int[]{1,2,3,4,5,6}; Integer[] order = new Integer[]{4,3,6,2,1,7}; Arrays.sort(order, new Comparator<Integer>() { public int compare(Integer idx1, Integer idx2) { return data[idx1] - data[idx2]; } }); }

Anonymous on May 22, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.