Add a helper function to sort projects by a string property

Created on 4 August 2025, 9 days ago

Problem/Motivation

The DrupalCore and Recipes sources have some copypasta code to sort projects by title:

      $sort = $query['sort'];
      switch ($sort) {
        case 'a_z':
          usort($projects, fn($x, $y) => $x->title <=> $y->title);
          break;

        case 'z_a':
          usort($projects, fn($x, $y) => $y->title <=> $x->title);
          break;
      }

This should use natural sorting (strnatcmp) and be a static helper method in SortHelper, rather than copypasta.

✨ Feature request
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • Merge request !856Add sort helper method β†’ (Open) created by phenaproxima
  • Pipeline finished with Failed
    9 days ago
    Total: 433s
    #563857
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Actually, I've discovered that the sorting code in the backend is kind of a mess and should be cleaned up before we roll a stable release. Tagging accordingly.

  • Pipeline finished with Canceled
    9 days ago
    Total: 120s
    #563862
  • Pipeline finished with Failed
    9 days ago
    Total: 481s
    #563863
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • Pipeline finished with Running
    9 days ago
    #564231
  • Pipeline finished with Failed
    9 days ago
    #564232
  • Pipeline finished with Failed
    9 days ago
    #564236
  • Pipeline finished with Failed
    9 days ago
    #564244
  • Pipeline finished with Failed
    9 days ago
    #564281
Production build 0.71.5 2024