Show 1st, 2nd and 3rd Places With a Spreadsheet

This tutorial explains how to use the SORTN function in Google Sheets to find the top three places, including the ties.

When you have to sort out the first, second, and third place in a spreadsheet, it can be tricky to determine the winners if there are results with the same time. Although you could sort the data by the relevant column, this will rearrange the rows and return all the race times instead of the top finishers.

Therefore, we will use SORTN, to concisely list the winners, and for that, we will take race times as input, where the smallest values rank higher. The table below shows our list of times from a recent race.

Get a copy of the race times spreadsheet with the solutions to follow along.

Unsorted Source Data

Run TimeFirst NameLast Name
4.77EwartAdelyn
2.97BoyceAyala
2.48AndreDuran
2.97EmmettGrant
4.50VitoHorn
3.54CarlaMarquez
5.18HoytMelton
2.48ArlineMyers
2.97WinifredRamos
3.88AdamSteinfurth

SORTN Syntax

Before we dive into the formulas, let’s look at the syntax of the SORTN function.

=SORTN(range,[n],[display_ties_mode],[sort_column1, is_acending1],...)

  • range – The range of data for the function to sort
  • n – The number of items to return
  • display_ties_mode [OPTIONAL] – An optional number designating how to display ties.
    • 0: Show the first n rows in the sorted range.
    • 1: Show the first n rows, plus any additional rows identical to the nth row.
    • 2: Show the first n rows after removing duplicate rows.
    • 3: Show the first n unique rows, but show every duplicate of these rows. 
  • sort_column1 [OPTIONAL] – The column with the criteria you are sorting. It can only be one column at a time. If this value is not specified, the function will use the lowest index column in the range and subsequent columns if a tie-breaker is needed.
  • is_ascending1 [OPTIONAL] – Two possible answers – TRUE for ascending (1,2,3), FALSE for descending (3,2,1)
  • sort_column2 - [OPTIONAL] – Add as many of these as you want.

As you can see from the syntax, this function is built to create sorted lists and deal with ties. Let’s put it to the test.

Top Three Times Ignoring Ties

We’ll start with showing the top three times using the SORTN function. SORTN has a built-in display_ties_mode, which we will change in the subsequent examples to give us different results.

In this first example, we will point the function to the range of A2:C11, which is the unsorted list of race results. We’ll ask for the first three results by specifying 3 for the n parameter. n is the number of results for the function to return.

Top three times
Top Three Times

Formula used in cell E4 =SORTN(A2:C11,3)

The function returns the top three times. But what about Grant Emmett (row 5) and Ramos Winifred (row 10)? They also placed third as their times are tied with Ayala‘s 2.97. Fortunately, the SORTN function can handle this situation if we change the display_ties_mode argument. Let’s look at that next.

The Three Fastest Race Times – Including Ties

Now, let’s find the top racers that got the fastest three times, including ties. To do this, we will change the display_ties_mode to 3, which shows the top three unique times, including ties. We will also use a 1 to specify the sort column and a TRUE to sort in ascending order.

The runners with the top three times including all ties
Top Three Times Including Ties

Formula used in cell E4 =SORTN(A2:C11,3,3,1,TRUE)

The report shows the first, second, and third place runners and the runner with the third fastest time, which won’t place third because of the ties. This list of six runners may be the report you want. However, you are most likely looking for the next option. Let’s change the output to show only the runners in the top three spots.

First, Second, and Third Place Including Ties

This last example will show only the runners that placed in the top three. It could show more than three runners, depending on the number of ties. To do this, we will use a display_ties_mode of 1, displaying all duplicates of the third row if there are any.

The SORTN function showing the best three times and any repeats of the third value
Top Three Rows Including Ties of Last Row

The report is most likely what you are looking for. You can award first place to Andre Duran and Arline Myers, and third place to Boyce Ayala, Emmett Grant, and Winifred Ramos. There is no second place since there were two first place finishers.

Video Tutorial

See a YouTube tutorial on this subject.

YouTube player

Related Pages