code: public static <T extends CharSequence> Collection<T> findMinimum(
  			Collection<T> ss, CharSequence t, int n, int threshold) {
  		LinkedList<Item<T>> result = new LinkedList<>();
  		for (T s : ss) {
  			int d = StringUtils.getLevenshteinDistance(s, t);
  			if (d < threshold) {
  				result.offer(new Item<>(s, d));
  				
  				if (result.size() > n + 10) {
  					//resort, but not too often
  					Collections.sort(result);
  					while (result.size() > n) result.removeLast();
  				}
  			}
  		}
  		
  		Collections.sort(result);
  		while (result.size() > n) result.removeLast();
  		
  		List<T> arr = new ArrayList<>(n);
  		for (Item<T> i : result) {
  			arr.add(i.str);
  		}
  		return arr;
  	}
docs: Searches the given collection of strings and returns a collection of at
  most <code>n</code> strings that have the lowest Levenshtein distance
  to a given string <code>t</code>. The returned collection will be
  sorted according to the distance with the string with the lowest
  distance at the first position.
  @param <T> the type of the strings in the given collection
  @param ss the collection to search
  @param t the string to compare to
  @param n the maximum number of strings to return
  @param threshold a threshold for individual item distances. Only items
  with a distance below this threshold will be included in the result.
  @return the strings with the lowest Levenshtein distance