title: When sorting an array, in case of identical values how to assign shared ordinal suffixes?
body: <p>Weird title, stick with me:</p>
  <p>I have a method that gives me an ordinal (whatever it's called) based on the int that is provided:</p>
  <pre><code>public String ordinal(int i) {
  String[] suffixes = new String[] { &quot;th&quot;, &quot;st&quot;, &quot;nd&quot;, &quot;rd&quot;, &quot;th&quot;, &quot;th&quot;, &quot;th&quot;, &quot;th&quot;, &quot;th&quot;, &quot;th&quot; };
  switch (i % 100) {
  case 11:
  case 12:
  case 13:
      return i + &quot;th&quot;;
  default:
      return i + suffixes[i % 10];
    }
  }
  </code></pre>
  <p>So, <code>ordinal(1)</code> returns <code>1st</code></p>
  <p>Now the actual problem - I am using Comparator to sort objects based on one of their parameters:</p>
  <pre><code>public void sortClients(){
      sortedClients.addAll(clientList);
      sortedClients.sort(Comparator.comparing(Client::getScore).reversed());
      }
  </code></pre>
  <p>In the end I print them to the console like this:</p>
  <pre><code>int j = 1;
  for (int i = 0; i &lt; sortedClients.size(); i++) {
      System.out.println(ordinal(j) + &quot; &quot; + sortedClients.get(i).getName() + &quot; - &quot;
                      + sortedClients.get(i).getScore());
      j++;
      if (i == sortedClients.size() - 1) {
          j = 1;
      }
          }
  </code></pre>
  <p>This results in:</p>
  <pre><code>1st John Smith - 12.61
  2nd Adam West - 13.43
  3rd Roger - 13.43
  4th That man - 13.75
  </code></pre>
  <p>My goal is to get this result:</p>
  <pre><code>1st John Smith - 12.61
  2nd-3rd Adam West - 13.43
  2nd-3rd Roger - 13.43
  4th That man - 13.75
  </code></pre>
  <p>What sort of check do I have to do here to know when these clients have the same value (or do I somehow modify ordinal() instead)</p>