Drupal is a registered trademark of Dries Buytaert
drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). commerce 3.3.5 Minor update available for module commerce (3.3.5). geocoder 8.x-4.34 Minor update available for module geocoder (8.x-4.34). leaflet 10.4.5 Minor update available for module leaflet (10.4.5). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52).

The problem

Drupal Views sorts string fields alphabetically by default. When those strings contain numbers the result looks wrong:

  • Product 1
  • Product 10
  • Product 101
  • Product 15
  • Product 2

This module fixes that by applying SQL type casting directly in the ORDER BY clause; no pre-computed index tables, no custom SQL required from site builders.

Two sort handlers

Cast sort wraps the field in CAST(field AS type) before sorting. Use this for fields that store purely numeric values as strings: SKUs, reference numbers, serial numbers, rankings. Supports integer, decimal, date, datetime, and text cast types, configurable in the Views UI.

Trailing integer sort uses REGEXP_SUBSTR(field, '[0-9]+$') to extract the integer at the end of each value before casting. Use this for mixed strings such as "Product 10", "SKU-ref-207", or "Item 3B".

Requirements

Drupal 10 or 11
Trailing integer sort requires MySQL 8.0.4+ or MariaDB 10.0.5+. Cast sort works on all supported Drupal databases. An in-form warning and watchdog entry are shown if the database does not meet the requirement.
Relation to similar modules

Views Natural Sort solves a related problem using a pre-computed index approach. Views Cast Sort is a lighter alternative for the common case where you want numeric ordering of a string field without maintaining a separate index.

Activity

Total releases
1
First release
Apr 2026
Latest release
16 hours ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.0.x-dev Dev Apr 20, 2026