private static int[] getFirstK(double[] sum, int k) {
        Map<Integer, Double> m = new TreeMap<Integer, Double>();
        for (int i = 0; i < sum.length; i++) {
            m.put(i, sum[i]);
        }
        List<Map.Entry<Integer, Double>> mappingList = null;
        mappingList = new ArrayList<Map.Entry<Integer, Double>>(m.entrySet());
        Collections.sort(mappingList,
                new Comparator<Map.Entry<Integer, Double>>() {
                    public int compare(Map.Entry<Integer, Double> mapping1,
                            Map.Entry<Integer, Double> mapping2) {
                        return mapping1.getValue().compareTo(
                                mapping2.getValue());
                    }
                });

        Map<Integer, Double> newMap = new HashMap<Integer, Double>();
        int count = 0;
        for (Map.Entry<Integer, Double> mapping : mappingList) {
            newMap.put(mapping.getKey(), mapping.getValue());
            count++;
            if (count == k) {
                break;
            }
        }
        int array[] = new int[k];
        Iterator<Integer> iterator = newMap.keySet().iterator();
        while (iterator.hasNext() && k > 0) {
            array[k - 1] = (int) iterator.next();
            k--;
        }

        return array;
    }