Sorting a column seems to always put empty values last

#1

No matter whether you sort a column in ascending or descending order, rows with empty values in the column always appear last.

#2

Even in SQL (a relational calculus language) there is no definition in the standard for where NULLS should appear in an ORDER BY clause; by definition, a NULL value has no position. So, each database system makes its own decision on where NULLs should be sorted. Coda has chosen at the end. Some languages have the capability to choose to sort NULLs at the beginning or end, but by no means all.

Thankfully, you can achieve this result with a little bit of sleight-of-hand in Coda. :wink:

#3

NULL feels like a bit of a red herring to me – e.g., you use IsBlank() in your example, which is documented to return True for “”, and the empty string is not the same thing as NULL.

The Coda docs appear to be quite careful to avoid using the term NULL anywhere, preferring “blank” which appears to mean “NULL or the empty string”.

Actually properly supporting a NULL notion would be quite handy – it would mean you could distinguish between “This checkbox is not selected because the user made a conscious choice to unselect it” (value = False) vs. “This checkbox is not selected because the user hasn’t interacted with it yet” (value = NULL).

#4

You’re correct that NULLs and empty strings aren’t the same thing because NULLs aren’t the same as anything else; even the expression “NULL=NULL” is false. But in this case the concept of Blank isn’t really an empty string either or it would be sorted first as string sorts tend to do.

Anyway, it’s all academic. I only wanted to show that there was a workaround to sort them first. :wink:

1 Like