Skip to content

sortProjects SortValue lacks a descending-name case (asymmetrical with date) #20

Description

@ManningWorks

Context

Consuming @manningworks/projex (v1.3.0). The site offers a "Name (Z-A)" sort option in its UI.

Problem

sortProjects is asymmetrical. SortValue = 'stars' | 'name' | 'date' | 'date-asc' — date has both directions (date = desc, date-asc = asc), but name is ascending-only and stars is single-direction:

// dist/lib/sortProjects.js
case 'stars':    return sortByStars(projects)
case 'name':     return sortByName(projects, 'asc')
case 'date':     return sortByDate(projects, 'desc')
case 'date-asc': return sortByDate(projects, 'asc')

A consumer that offers a "Name Z-A" option cannot express it via sortProjects. The underlying sortByName(projects, 'desc') supports it fine, so the consumer is forced to drop down to the granular sorters and skip the convenience switch entirely — which makes sortProjects incomplete rather than the obvious top-level choice.

Proposal

Add 'name-desc' (and probably 'stars-desc'), e.g.:

export type SortValue = 'stars' | 'stars-desc' | 'name' | 'name-desc' | 'date' | 'date-asc'

…or make the whole enum order-aware so the asymmetry can't recur:

export type SortValue = { field: 'name' | 'date' | 'stars'; order: 'asc' | 'desc' }

Either way, once a descending-name case exists, sortProjects covers the full UI vocabulary and consumers don't need to reach past it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions