Skip to content

Sort null/undefined values to *end* in sortFunction / multiSortFunction #8356

Description

@grantfitzsimmons

Is your feature request related to a problem? Please describe.
Reported by Nate Shoobs, OSU Mollusks sorts determinations by date descending, with the current determination and most recent determinations first. This is done using the following form XML:

<row>
<cell type="subview" viewname="Determination" id="66" name="determinations" colspan="14" rows="5" initialize="sortfield=-DeterminedDate"/>
</row>

A problem arises when determinations do not have a known determinedDate. The null value sorts at the beginning of the set of determinations, even in front of the one marked "Current". OSU frequently adds prior determinations from old labels that don't have dates associated, and each addition without a date jumps to the top ahead of the current determination.

Describe the solution you'd like
We could add an explicit null check at the top of both sortFunction and multiSortFunction in specifyweb/frontend/js_src/lib/utils/utils.ts so that empty values always sort to the end of the list (SQL's NULLS LAST semantics), regardless of ascending or descending direction.

Reported By
Nate Shoobs — Ohio State University (OSU) on the Speciforum

Metadata

Metadata

Assignees

No one assigned

    Labels

    2 - User InterfaceIssues that are related to the user interface or user experience.UXUser experience issues that have been reported by a number of usersgood first issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions