Views Sort Expression
Part of the Views ecosystem · 208 projects
This module allows for advanced sorting of view results using custom SQL expressions. It enables sorting options not available in default handlers, such as displaying NULL values last or prioritizing certain content types.
This is an advanced module as it basically requires you to know the SQL of the view and how to construct expression-based ORDER BYs.
It aims to be a helper module which provides custom ordering that is normally not possible with default sort handlers.
By sorting by expressions you can do things like, showing NULL items last when sorting by a numeric field, or creating a custom sort order putting some content types on top. The possibilities are endless.
You may use whatever is currently available in the query. For that reason, you should always enable the "Show the SQL query" on the Views setting page to help you find the proper field aliases. Adding a field or the like to the view doesn't necessarily alter the SQL Query. You may find it useful to add what you need in the proper sort order, use it inside the expression, then rearrange your expression where you need it.
Depends on
Dependencies of the latest stable release
- views Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
More in the Views ecosystem
Most installed first
Activity
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 2.0.2 | Stable | 9–11 | Drupal 11 support and fix config schema warning. | Sep 8, 2026 |