private void limitSimilarities() {
		// sort the similarities by decreasing similarity and take the N most
		// similar users
		for (Map.Entry<Integer, LinkedHashMap<Integer, Double>> entry : similarities.entrySet()) {
			ArrayList<Entry<Integer, Double>> list = new ArrayList<Entry<Integer, Double>>(entry.getValue().entrySet());

			// sort by decreasing similarity
			Collections.sort(list, Collections.reverseOrder(comparator));

			// put the first N entry of list back into the LinkedHashMap

			LinkedHashMap<Integer, Double> limitedSimilarities = new LinkedHashMap<Integer, Double>();
			if (Recommender.isTreshold()) {
				// put the entries bigger than the threshold back into the
				// similarities map
				int k = 0;
				while (k < list.size()) {
					if (list.get(k).getValue() >= Recommender.getThreshold()) {
						limitedSimilarities.put(list.get(k).getKey(), list.get(k).getValue());
					}
					k++;
				}
			} else {
				// put the N = neighbourhoddSize biggest entries back into the
				// similarities map
				for (int j = 0; j < neighbourhoodSize; j++) {
					if (j < list.size()) {
						limitedSimilarities.put(list.get(j).getKey(), list.get(j).getValue());
					}
				}
			}
			similarities.put(entry.getKey(), limitedSimilarities);
		}
	}