public static List<Integer> getKNearestMovies(int k, int index)
  {
    SparseVector base = colMatrix.get(index);
    List<Integer> nearestIndices = new ArrayList<Integer>();
    List<Double> nearestScores = new ArrayList<Double>();
    for (int i=0; i<colMatrix.size(); i++){
      if (i == index) continue;
      double score = colMatrix.get(i).distanceFrom(base);
      if (nearestIndices.size()==0){
        nearestIndices.add(i);
        nearestScores.add(score);
      }else if (nearestIndices.size()<k){
        for (int j=0; j<nearestIndices.size(); j++){
          if (score < nearestScores.get(j)){
            nearestScores.add(j, score);
            nearestIndices.add(j, i);
            break;
          }
        }
      }else{
        for (int j=0; j<nearestIndices.size(); j++){
          if (score < nearestScores.get(j)){
            nearestScores.add(j, score);
            nearestIndices.add(j, i);
            nearestScores.remove(nearestIndices.size()-1);
            nearestIndices.remove(nearestIndices.size()-1);
            break;
          }
        }        
      }
    }
    return nearestIndices;
  }