Skip to content

Case-sensitive sorting for Media 'filename' causes unintuitive grouping #14517

@skrzepij

Description

@skrzepij

Describe the Bug

Current behavior

In Payload CMS admin panel, sorting Media collection by the system-managed field filename is case-sensitive, which causes filenames to be grouped into two clusters:

  • Files with uppercase first letters,
  • Followed by files with lowercase first letters.

Example:

A_file.png
B_file.png
a_file.png
b_file.png

The admin panel sends requests like /admin/collections/media?sort=filename&..., but the sorted output does not ignore letter case.

Why this is a problem

  • Users expect alphabetical sorting that ignores case, i.e., case-insensitive sorting,
  • Current behavior is confusing and unintuitive for end users,
  • Working around this requires custom fields, hooks, and UI overrides,

Relation to existing discussion

There is an open GitHub Discussion #8005 discussing similar case-sensitive sorting issues, but it focuses primarily on sorting in other collections (e.g., posts) and not the system field filename in the Media collection specifically.

This issue is related but addresses a distinct and important use case affecting media filename sorting.

Suggested improvement

  • Provide native support for case-insensitive sorting on system fields like filename in the admin panel,
  • Allow configuration of sorting sensitivity per field or collection,
  • Improve documentation to guide developers how to handle case-insensitive sorting on system and custom fields.

Link to the code that reproduces this issue

https://github.com/payloadcms/payload

Reproduction Steps

  1. Log in to Payload CMS admin panel.
  2. Navigate to the Media collection.
  3. Ensure media entries with filenames starting with uppercase and lowercase letters exist (e.g., A_file.png, a_file.png).
  4. Click on the column header for Filename to sort the media entries by filename.
  5. Observe that media files are sorted case-sensitively, with uppercase-leading filenames grouped before lowercase-leading filenames.
  6. Inspect the network request URL, which includes sort=filename and confirms sorting request.
  7. Verify the visual ordering and note it does not match expected case-insensitive alphabetical sort.

Which area(s) are affected? (Select all that apply)

Not sure

Environment Info

Binaries:
  Node: 22.14.0
  pnpm: 10.3.0
Relevant Packages:
  payload: 3.59.1
  next: 15.4.4
  @payloadcms/db-sqlite: 3.59.1
  @payloadcms/drizzle: 3.59.1
  @payloadcms/email-nodemailer: 3.59.1
  @payloadcms/graphql: 3.59.1
  @payloadcms/live-preview: 3.59.1
  @payloadcms/live-preview-react: 3.59.1
  @payloadcms/next/utilities: 3.59.1
  @payloadcms/payload-cloud: 3.59.1
  @payloadcms/richtext-lexical: 3.59.1
  @payloadcms/translations: 3.59.1
  @payloadcms/ui/shared: 3.59.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions