Experimental project
This is a sandbox project, which contains experimental code for developer use only.
A Views plugin to replace on selected views the default "staggered" sort by a "merged" sort.
Say you have a View of two content types. Each has incarnations of a similar, but not identical field, i.e. fields with different machine names. One field may be fruit colour, while the other one is car colour. Each may have a different range of allowed values (i.e. taxonomy or list).
For our purpose, let's say we're dealing with distance fields, as available through the Geofield and Location modules.
You want to sort all your locations (rows) by ascending distance to some reference point. However, as each content type has its own distance field, sorting will be on one distance field first, the other second. That's just the way databases operate, by default.
| Distance | Distance |
| Field 1 | Field 2 |
----------------------------------|
location #1 | 0.3 km | -- |
location #2 | 1.4 km | -- |
location #3 | 2.3 km | -- |
location #4 | -- | 0.1 km |
location #5 | -- | 1.5 km |
So, not only is the order not what we want, if a limit is placed on the number of items returned, say 3 in the example above, then the second content type may not be represented in the output at all.
This module sorts out your sorting. Flick it on for the View displays that need it and your output will look like this:
| Distance | Distance |
| Field 1 | Field 2 |
----------------------------------|
location #4 | -- | 0.1 km |
location #1 | 0.3 km | -- |
location #2 | 1.4 km | -- |
location #5 | -- | 1.5 km |
location #3 | 2.3 km | -- |
With this module enabled you can select the views that need the merge-sort treatment here: admin/config/content/views_merge_sort
Project information
- Created by rdeboer on , updated

