Sort
Share
Explore

icon picker
Sort

Formula: Sort()
Category: Collections
alphabetical-sorting (1).svg
Sort()
Sorts a list or a column
Or, put otherwise...
Hey Coda, I’m going to give you a list. Can you sort that list either alphabetically or numerically. Oh! Can you also sort it with A-Z or Z-A?

Sort() has only one required parameter:
database.svg
Dataset

Sort(Dataset)

The column or list that you want to sort.

Sort() has three optional parameters:
generic-sorting (1).svg
Ascending

Sort(Dataset, Ascending, SortBy, SortByCount)

True = ascending; False = descending. Defaults to true.
alphabetical-sorting-2.svg
SortBy

Sort(Dataset, Ascending, SortBy, SortByCount)

What you want to sort the table on (i.e., a specific column).
100.svg
SortByCount

Sort(Dataset, Ascending, SortBy, SortByCount)

True = sort by count; False = sort by value. Defaults to true.

In early grade school, organizing words in Alphabetical order is a big deal. If early grade school was a nightmare for you, Sort() will be your friend.
Sort() takes a list and then:
If it’s a list of words/sentences will sort them alphabetically.
If it’s a list of number values/dates, will sort them from lowest to highest.
Play around with the toggles below to see how Sort() and its Ascending parameter is working.
See the lists as unsorted
sorted
Sort Direction: 9 → 1
1 → 9
886762594846393526241614141211
Sort Direction: Z-A
A-Z
RabbitHorseGoose breedsGoatFancy rat varietiesDonkeyDogChicken breedsCattle

Alright - now what about all that other parameters? What is it for?

SortBy

SortBy is an optional parameter. Click into the lists of animals or numbers above and notice that you will not find it anywhere in those formula.
Where SortBy comes in handy is when you are trying to grab a sorted list of a table and want access to all the column values.
For example, let say you needed a list of the first 5 birthdays in this calendar year of people from the . The only way to accomplish that is with the SortBy parameter.
5 Earliest Birthdays!

@Thomas Fisher
@Nathan Garcia
@Ronnie Gross
@Matthew Smith
@Robert Serrano
Hover over each of the blue names above and you will see that their birthdays all fall in early January.

Done
Sort a list of people ascending and descending by multiple different factors
Done
Help build a dashboard for a client by pulling out formatted information from a table
Done

Ready to master Coda yourself?


Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.