sima-sorting

Map URL sort fields to MongoDB sort objects with allowlist validation.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/RosenGray/sima --skill sima-sorting
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sima-sorting
Source: https://github.com/RosenGray/sima/tree/main/.cursor/skills/sima-sorting
Command: npx skills add https://github.com/RosenGray/sima --skill sima-sorting

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill defines a reusable pattern for sorting across listing pages, unifying UI, backend, and URL-driven state to ensure consistent results.

Core Features & Use Cases

  • Reusable SortFilters UI for selecting sort options across sections
  • Server-side interpretation of sort strings via a repository pattern that safely maps fields to DB fields
  • URL-driven state with query parameters to preserve filters and reset pagination on changes
  • Example: sort cars, pets, or other listings by date, year, price, or mileage with deterministic pagination

Quick Start

Load a listing page, choose a sort (e.g., date_desc or price_asc), and observe the URL update. The page resets to the first page on sort changes and preserves existing filters.

Frequently Asked Questions about sima-sorting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement URL-driven sorting for MongoDB listing pages?

URL-driven sorting for MongoDB listing pages is implemented by mapping user-facing sort fields from URL parameters to backend MongoDB sort objects via a repository pattern. This unifies UI components and repository logic to ensure consistent query results.

How does pagination stay consistent when users change the sort order on a listings page?

Pagination consistency during sort changes is maintained by applying a deterministic tiebreaker to the MongoDB sort object. The system also resets the page URL parameters to the first page whenever a new sort option is selected.

Can I preserve existing filters when a user changes the sort option on a listing page?

Existing filters are preserved when changing sort options by carrying over the current URL query parameters. The sorting system updates only the sort parameter in the URL while keeping all other active filter states intact.

What is the best way to validate user-selected sort fields against allowed MongoDB columns?

Validating user-selected sort fields against allowed MongoDB columns is handled using input allowlists. If a submitted sort parameter is invalid, the system automatically applies a predefined defaultSort to prevent unsafe database queries.

Does this sorting pattern support different sort options for separate UI listing sections?

Different sort options for separate UI listing sections are supported through per-section sort configurations. Each section can define its own available sort fields while sharing the same underlying URL-driven state and repository mapping logic.