code: protected void printRanking(final String user, final Map<Long, Double> scoredItems, final PrintStream out, final OUTPUT_FORMAT format) {
          final Map<Double, Set<Long>> preferenceMap = new HashMap<Double, Set<Long>>();
          for (Map.Entry<Long, Double> e : scoredItems.entrySet()) {
              long item = e.getKey();
              double pref = e.getValue();
              // ignore NaN's
              if (Double.isNaN(pref)) {
                  continue;
              }
              Set<Long> items = preferenceMap.get(pref);
              if (items == null) {
                  items = new HashSet<Long>();
                  preferenceMap.put(pref, items);
              }
              items.add(item);
          }
          final List<Double> sortedScores = new ArrayList<Double>(preferenceMap.keySet());
          Collections.sort(sortedScores, Collections.reverseOrder());
          // Write estimated preferences
          int pos = 1;
          for (double pref : sortedScores) {
              for (long itemID : preferenceMap.get(pref)) {
                  switch (format) {
                      case TRECEVAL:
                          out.println(user + "\tQ0\t" + itemID + "\t" + pos + "\t" + pref + "\t" + "r");
                          break;
                      default:
                      case SIMPLE:
                          out.println(user + "\t" + itemID + "\t" + pref);
                          break;
                  }
                  pos++;
              }
          }
      }
docs: Print the item ranking and scores for a specific user.
  
  @param user The user (as a String).
  @param scoredItems The item to print rankings for.
  @param out Where to direct the print.
  @param format The format of the printer.