diff --git a/config/schema/facets.processor.schema.yml b/config/schema/facets.processor.schema.yml
index 0e10515..37c18fa 100644
--- a/config/schema/facets.processor.schema.yml
+++ b/config/schema/facets.processor.schema.yml
@@ -6,14 +6,6 @@ plugin.plugin_configuration.facets_processor.count_widget_widget_order:
       type: string
       label: sort order
 
-plugin.plugin_configuration.facets_processor.display_value_widget_order:
-  type: mapping
-  label: 'Display value widget order'
-  mapping:
-    sort:
-      type: string
-      label: sort order
-
 plugin.plugin_configuration.facets_processor.exclude_specified_items:
   type: mapping
   label: 'Exclude specified items'
@@ -25,30 +17,6 @@ plugin.plugin_configuration.facets_processor.exclude_specified_items:
       type: boolean
       label: Regex
 
-plugin.plugin_configuration.facets_processor.raw_value_widget_order:
-  type: mapping
-  label: 'Raw value widget order'
-  mapping:
-    sort:
-      type: string
-      label: sort order
-
-plugin.plugin_configuration.facets_processor.active_widget_order:
-  type: mapping
-  label: 'Active widget order'
-  mapping:
-    sort:
-      type: string
-      label: sort order
-
-plugin.plugin_configuration.facets_processor.count_widget_order:
-  type: mapping
-  label: 'Active widget order'
-  mapping:
-    sort:
-      type: string
-      label: sort order
-
 plugin.plugin_configuration.facets_processor.count_limit:
   type: mapping
   label: 'Count limit widget'
@@ -60,6 +28,16 @@ plugin.plugin_configuration.facets_processor.count_limit:
       type: integer
       label: 'Maximum amount of items to show.'
 
+plugin.plugin_configuration.facets_processor.sort_processor_handler:
+  type: mapping
+  label: settings
+  settings:
+    type: sequence
+    label: 'Facet sort processor configuration.'
+    sequence:
+      type: plugin.plugin_configuration.facets_sort_processor.[%key]
+      label: 'Facet plugin options'
+
 plugin.plugin_configuration.facets_processor.url_processor_handler:
   type: config_object
 
diff --git a/config/schema/facets.sort_processor.schema.yml b/config/schema/facets.sort_processor.schema.yml
new file mode 100644
index 0000000..b0d5ff9
--- /dev/null
+++ b/config/schema/facets.sort_processor.schema.yml
@@ -0,0 +1,31 @@
+plugin.plugin_configuration.facets_sort_processor.raw_value_widget_order:
+  type: mapping
+  label: 'Raw value widget order'
+  mapping:
+    sort:
+      type: string
+      label: sort order
+
+plugin.plugin_configuration.facets_sort_processor.active_widget_order:
+  type: mapping
+  label: 'Active widget order'
+  mapping:
+    sort:
+      type: string
+      label: sort order
+
+plugin.plugin_configuration.facets_sort_processor.count_widget_order:
+  type: mapping
+  label: 'Active widget order'
+  mapping:
+    sort:
+      type: string
+      label: sort order
+
+plugin.plugin_configuration.facets_sort_processor.display_value_widget_order:
+  type: mapping
+  label: 'Display value widget order'
+  mapping:
+    sort:
+      type: string
+      label: sort order
diff --git a/facets.services.yml b/facets.services.yml
index 1be585e..811b1f2 100644
--- a/facets.services.yml
+++ b/facets.services.yml
@@ -14,6 +14,9 @@ services:
   plugin.manager.facets.url_processor:
     class: Drupal\facets\UrlProcessor\UrlProcessorPluginManager
     parent: default_plugin_manager
+  plugin.manager.facets.sort_processor:
+    class: Drupal\facets\SortProcessor\SortProcessorPluginManager
+    parent: default_plugin_manager
   facets.manager:
     class: Drupal\facets\FacetManager\DefaultFacetManager
     arguments:
diff --git a/src/Annotation/FacetsSortProcessor.php b/src/Annotation/FacetsSortProcessor.php
new file mode 100644
index 0000000..42a83ea
--- /dev/null
+++ b/src/Annotation/FacetsSortProcessor.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\facets\Annotation\FacetsSortProcessor.
+ */
+
+namespace Drupal\facets\Annotation;
+
+use Drupal\Component\Annotation\Plugin;
+
+/**
+ * Defines a Facets sort processor annotation.
+ *
+ * @see \Drupal\facets\SortProcessor\SortProcessorPluginManager
+ * @see plugin_api
+ *
+ * @ingroup plugin_api
+ *
+ * @Annotation
+ */
+class FacetsSortProcessor extends Plugin {
+
+  /**
+   * The sort processor plugin id.
+   *
+   * @var string
+   */
+  public $id;
+
+  /**
+   * The human-readable name of the sort processor plugin.
+   *
+   * @ingroup plugin_translatable
+   *
+   * @var \Drupal\Core\Annotation\Translation
+   */
+  public $label;
+
+  /**
+   * The sort processor description.
+   *
+   * @ingroup plugin_translatable
+   *
+   * @var \Drupal\Core\Annotation\Translation
+   */
+  public $description;
+
+}
diff --git a/src/Form/FacetDisplayForm.php b/src/Form/FacetDisplayForm.php
index dc77639..2c68ec0 100644
--- a/src/Form/FacetDisplayForm.php
+++ b/src/Form/FacetDisplayForm.php
@@ -7,17 +7,19 @@
 
 namespace Drupal\facets\Form;
 
-use Drupal\Core\Config\Config;
 use Drupal\Component\Utility\Html;
+use Drupal\Core\Config\Config;
 use Drupal\Core\Entity\EntityForm;
-use Drupal\Core\Entity\EntityTypeManager;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\facets\Processor\ProcessorInterface;
 use Drupal\facets\Processor\ProcessorPluginManager;
+use Drupal\facets\SortProcessor\SortProcessorInterface;
+use Drupal\facets\SortProcessor\SortProcessorPluginManager;
 use Drupal\facets\UrlProcessor\UrlProcessorInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
 use Drupal\facets\Widget\WidgetPluginManager;
-use Drupal\facets\Processor\WidgetOrderProcessorInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
 
 /**
  * Provides a form for configuring the processors of a facet.
@@ -53,35 +55,48 @@ class FacetDisplayForm extends EntityForm {
   protected $widgetPluginManager;
 
   /**
+   * The plugin manager for sort processors.
+   *
+   * @var \Drupal\facets\Widget\WidgetPluginManager
+   */
+  protected $sortProcessorPluginManager;
+
+  /**
    * Constructs an FacetDisplayForm object.
    *
-   * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    *   The entity manager.
    * @param \Drupal\facets\Processor\ProcessorPluginManager $processor_plugin_manager
    *   The processor plugin manager.
    * @param \Drupal\facets\Widget\WidgetPluginManager $widget_plugin_manager
-   *   The plugin manager for widgets.
+   *   The widget plugin manager.
+   * @param \Drupal\facets\SortProcessor\SortProcessorPluginManager $sort_processor_plugin_manager
+   *   The sort processor plugin manager.
    */
-  public function __construct(EntityTypeManager $entity_type_manager, ProcessorPluginManager $processor_plugin_manager, WidgetPluginManager $widget_plugin_manager) {
+  public function __construct(EntityTypeManagerInterface $entity_type_manager, ProcessorPluginManager $processor_plugin_manager, WidgetPluginManager $widget_plugin_manager, SortProcessorPluginManager $sort_processor_plugin_manager) {
     $this->entityTypeManager = $entity_type_manager;
     $this->processorPluginManager = $processor_plugin_manager;
     $this->widgetPluginManager = $widget_plugin_manager;
+    $this->sortProcessorPluginManager = $sort_processor_plugin_manager;
   }
 
   /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container) {
-    /** @var \Drupal\Core\Entity\EntityTypeManager $entity_type_manager */
+    /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
     $entity_type_manager = $container->get('entity_type.manager');
 
     /** @var \Drupal\facets\Processor\ProcessorPluginManager $processor_plugin_manager */
     $processor_plugin_manager = $container->get('plugin.manager.facets.processor');
 
+    /** @var \Drupal\facets\Processor\ProcessorPluginManager $processor_plugin_manager */
+    $sort_processor_plugin_manager = $container->get('plugin.manager.facets.sort_processor');
+
     /** @var \Drupal\facets\Widget\WidgetPluginManager $widget_plugin_manager */
     $widget_plugin_manager = $container->get('plugin.manager.facets.widget');
 
-    return new static($entity_type_manager, $processor_plugin_manager, $widget_plugin_manager);
+    return new static($entity_type_manager, $processor_plugin_manager, $widget_plugin_manager, $sort_processor_plugin_manager);
   }
 
   /**
@@ -117,7 +132,8 @@ class FacetDisplayForm extends EntityForm {
       // @todo Create, use and save SubFormState already here, not only in
       //   validate(). Also, use proper subset of $form for first parameter?
       $config = $this->config('facets.facet.' . $this->entity->id());
-      if ($config_form = $widget_instance->buildConfigurationForm([], $form_state, ($config instanceof Config) ? $config : NULL)) {
+      $config = ($config instanceof Config) ? $config : NULL;
+      if ($config_form = $widget_instance->buildConfigurationForm([], $form_state, $config)) {
         $form['widget_configs']['#type'] = 'fieldset';
         $form['widget_configs']['#title'] = $this->t('%widget settings', ['%widget' => $this->getWidgetPluginManager()->getDefinition($widget)['label']]);
 
@@ -218,8 +234,9 @@ class FacetDisplayForm extends EntityForm {
         ),
       ),
     );
+
     foreach ($all_processors as $processor_id => $processor) {
-      if (!($processor instanceof WidgetOrderProcessorInterface) && !($processor instanceof UrlProcessorInterface)) {
+      if (!($processor instanceof UrlProcessorInterface)) {
         $clean_css_id = Html::cleanCssIdentifier($processor_id);
         $form['facet_settings'][$processor_id]['status'] = array(
           '#type' => 'checkbox',
@@ -236,10 +253,8 @@ class FacetDisplayForm extends EntityForm {
           '#access' => !$processor->isHidden(),
         );
 
-        $processor_form_state = new SubFormState(
-          $form_state,
-          ['facet_settings', $processor_id, 'settings']
-        );
+        $sub_keys = ['facet_settings', $processor_id, 'settings'];
+        $processor_form_state = new SubFormState($form_state, $sub_keys);
         $processor_form = $processor->buildConfigurationForm($form, $processor_form_state, $facet);
         if ($processor_form) {
           $form['facet_settings'][$processor_id]['settings'] = array(
@@ -263,6 +278,7 @@ class FacetDisplayForm extends EntityForm {
         }
       }
     }
+
     // Add the list of widget sort processors with checkboxes to enable/disable
     // them.
     $form['facet_sorting'] = array(
@@ -274,47 +290,56 @@ class FacetDisplayForm extends EntityForm {
         ),
       ),
     );
-    foreach ($all_processors as $processor_id => $processor) {
-      if ($processor instanceof WidgetOrderProcessorInterface) {
-        $clean_css_id = Html::cleanCssIdentifier($processor_id);
-        $form['facet_sorting'][$processor_id]['status'] = array(
-          '#type' => 'checkbox',
-          '#title' => (string) $processor->getPluginDefinition()['label'],
-          '#default_value' => $processor->isLocked() || !empty($enabled_processors[$processor_id]),
-          '#description' => $processor->getDescription(),
+
+    $sorting_settings = $all_processors['sort_processor_handler']->getConfiguration();
+
+    foreach ($this->sortProcessorPluginManager->getDefinitions() as $processor_id => $definition) {
+      $processor = $this->sortProcessorPluginManager->createInstance($processor_id);
+      $clean_css_id = Html::cleanCssIdentifier($processor_id);
+      $is_checked = !empty($sorting_settings[$processor_id]) && $sorting_settings[$processor_id]['status'];
+      $form['facet_sorting'][$processor_id]['status'] = array(
+        '#type' => 'checkbox',
+        '#title' => (string) $processor->getPluginDefinition()['label'],
+        '#default_value' => $processor->isLocked() || $is_checked,
+        '#description' => $processor->getDescription(),
+        '#attributes' => array(
+          'class' => array(
+            'search-api-processor-status-' . $clean_css_id,
+          ),
+          'data-id' => $clean_css_id,
+        ),
+        '#disabled' => $processor->isLocked(),
+        '#access' => !$processor->isHidden(),
+      );
+
+      $sub_keys = ['facet_sorting', $processor_id, 'settings'];
+      $processor_form_state = new SubFormState($form_state, $sub_keys);
+      $processor_form = $processor->buildConfigurationForm($form, $processor_form_state, $facet);
+      if ($processor_form) {
+        $form['facet_sorting'][$processor_id]['settings'] = array(
+          '#type' => 'container',
+          '#open' => TRUE,
           '#attributes' => array(
             'class' => array(
-              'search-api-processor-status-' . $clean_css_id,
+              'facets-processor-settings-' . Html::cleanCssIdentifier($processor_id),
+              'facets-processor-settings-sorting',
+              'facets-processor-settings',
+            ),
+          ),
+          '#parents' => ['facet_sorting', $processor_id],
+          '#states' => array(
+            'visible' => array(
+              ':input[name="facet_sorting[' . $processor_id . '][status]"]' => array('checked' => TRUE),
             ),
-            'data-id' => $clean_css_id,
           ),
-          '#disabled' => $processor->isLocked(),
-          '#access' => !$processor->isHidden(),
         );
+        $form['facet_sorting'][$processor_id]['settings'] += $processor_form;
 
-        $processor_form_state = new SubFormState(
-          $form_state,
-          array('facet_sorting', $processor_id, 'settings')
-        );
-        $processor_form = $processor->buildConfigurationForm($form, $processor_form_state, $facet);
-        if ($processor_form) {
-          $form['facet_sorting'][$processor_id]['settings'] = array(
-            '#type' => 'container',
-            '#open' => TRUE,
-            '#attributes' => array(
-              'class' => array(
-                'facets-processor-settings-' . Html::cleanCssIdentifier($processor_id),
-                'facets-processor-settings-sorting',
-                'facets-processor-settings',
-              ),
-            ),
-            '#states' => array(
-              'visible' => array(
-                ':input[name="facet_sorting[' . $processor_id . '][status]"]' => array('checked' => TRUE),
-              ),
-            ),
-          );
-          $form['facet_sorting'][$processor_id]['settings'] += $processor_form;
+        // Make sure that settings are saved as expected.
+        if (count($sorting_settings) > 0 && isset($sorting_settings[$processor_id])) {
+          foreach ($sorting_settings[$processor_id]['settings'] as $k => $value) {
+            $form['facet_sorting'][$processor_id]['settings'][$k]['#default_value'] = $value;
+          }
         }
       }
     }
@@ -494,24 +519,22 @@ class FacetDisplayForm extends EntityForm {
     $values = $form_state->getValues();
 
     // Store processor settings.
-    // @todo Go through all available processors, enable/disable with method on
-    //   processor plugin to allow reaction.
     /** @var \Drupal\facets\FacetInterface $facet */
     $facet = $this->entity;
 
     /** @var \Drupal\facets\Processor\ProcessorInterface $processor */
     $processors = $facet->getProcessors(FALSE);
     foreach ($processors as $processor_id => $processor) {
-      $form_container_key = $processor instanceof WidgetOrderProcessorInterface ? 'facet_sorting' : 'facet_settings';
+      $form_container_key = $processor instanceof SortProcessorInterface ? 'facet_sorting' : 'facet_settings';
       if (empty($values[$form_container_key][$processor_id]['status'])) {
         $facet->removeProcessor($processor_id);
         continue;
       }
-      $new_settings = array(
+      $new_settings = [
         'processor_id' => $processor_id,
-        'weights' => array(),
-        'settings' => array(),
-      );
+        'weights' => [],
+        'settings' => [],
+      ];
       if (!empty($values['processors'][$processor_id]['weights'])) {
         $new_settings['weights'] = $values['processors'][$processor_id]['weights'];
       }
@@ -523,6 +546,12 @@ class FacetDisplayForm extends EntityForm {
         $processor->submitConfigurationForm($form[$form_container_key][$processor_id]['settings'], $processor_form_state, $facet);
         $new_settings['settings'] = $processor->getConfiguration();
       }
+
+      // The sort processor handler should have the settings for all sorting
+      // facets.
+      if ($processor_id === 'sort_processor_handler') {
+        $new_settings['settings'] = $values['facet_sorting'];
+      }
       $facet->addProcessor($new_settings);
     }
 
diff --git a/src/Plugin/facets/processor/SortProcessorHandler.php b/src/Plugin/facets/processor/SortProcessorHandler.php
new file mode 100644
index 0000000..56d3a66
--- /dev/null
+++ b/src/Plugin/facets/processor/SortProcessorHandler.php
@@ -0,0 +1,93 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\facets\Plugin\facets\processor\SortProcessorHandler.
+ */
+
+namespace Drupal\facets\Plugin\facets\processor;
+
+use Drupal\facets\Exception\InvalidProcessorException;
+use Drupal\facets\FacetInterface;
+use Drupal\facets\Processor\BuildProcessorInterface;
+use Drupal\facets\Processor\ProcessorPluginBase;
+use Drupal\facets\Result\Result;
+
+/**
+ * The sort processor handler to manager the sorting.
+ *
+ * @FacetsProcessor(
+ *   id = "sort_processor_handler",
+ *   label = @Translation("Sort handler"),
+ *   description = @Translation("Handles sorting of results."),
+ *   stages = {
+ *     "build" = 20,
+ *   },
+ *   locked = true
+ * )
+ */
+class SortProcessorHandler extends ProcessorPluginBase implements BuildProcessorInterface {
+
+  /**
+   * The used facet.
+   *
+   * @var \Drupal\facets\FacetInterface
+   */
+  protected $facet;
+
+  /**
+   * The sorts enabled for facet.
+   */
+  protected $sorts = [];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+
+    if (!isset($configuration['facet']) || !$configuration['facet'] instanceof FacetInterface) {
+      throw new InvalidProcessorException("The SortProcessorHandler doesn't have the required 'facet' in the configuration array.");
+    }
+
+    /** @var \Drupal\facets\FacetInterface $facet */
+    $this->facet = $configuration['facet'];
+
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function build(FacetInterface $facet, array $results) {
+    $processors = $facet->getProcessors();
+    $sort_processor_handler = $processors['sort_processor_handler'];
+    $configs = $sort_processor_handler->getConfiguration();
+
+    $plugin_manager = \Drupal::getContainer()->get('plugin.manager.facets.sort_processor');
+
+    foreach ($configs as $id => $sort_config) {
+      if ($sort_config['status'] == TRUE) {
+        /** @var \Drupal\facets\SortProcessor\SortProcessorInterface $sort */
+        $this->sorts[] = $plugin_manager->createInstance($id, $sort_config);
+      }
+    }
+
+    uasort($results, array($this, 'sortCallback'));
+
+    return $results;
+  }
+
+  /**
+   * Applies sorts and return the sorting information for uasort().
+   */
+  protected function sortCallback(Result $a, Result $b) {
+    $return = 0;
+    foreach ($this->sorts as $sort) {
+      if ($return = $sort->sortResults($a, $b)) {
+        break;
+      }
+    }
+    return $return;
+  }
+
+}
diff --git a/src/Plugin/facets/processor/UrlProcessorHandler.php b/src/Plugin/facets/processor/UrlProcessorHandler.php
index 8779a8f..329ecb5 100644
--- a/src/Plugin/facets/processor/UrlProcessorHandler.php
+++ b/src/Plugin/facets/processor/UrlProcessorHandler.php
@@ -27,7 +27,7 @@ use Drupal\facets\Processor\ProcessorPluginBase;
  *   description = @Translation("Triggers the URL processor, which is set in the Facet source configuration."),
  *   stages = {
  *     "pre_query" = 50,
- *     "build" = 15,
+ *     "build" = 25,
  *   },
  *   locked = true
  * )
diff --git a/src/Plugin/facets/processor/ActiveWidgetOrderProcessor.php b/src/Plugin/facets/sort_processor/ActiveWidgetOrderProcessor.php
similarity index 59%
rename from src/Plugin/facets/processor/ActiveWidgetOrderProcessor.php
rename to src/Plugin/facets/sort_processor/ActiveWidgetOrderProcessor.php
index 2b125c7..207ce67 100644
--- a/src/Plugin/facets/processor/ActiveWidgetOrderProcessor.php
+++ b/src/Plugin/facets/sort_processor/ActiveWidgetOrderProcessor.php
@@ -2,20 +2,18 @@
 
 /**
  * @file
- * Contains \Drupal\facets\Plugin\facets\processor\ActiveWidgetOrderProcessor.
+ * Contains \Drupal\facets\Plugin\facets\sort_processor\ActiveWidgetOrderProcessor.
  */
 
-namespace Drupal\facets\Plugin\facets\processor;
+namespace Drupal\facets\Plugin\facets\sort_processor;
 
-
-use Drupal\facets\Processor\WidgetOrderPluginBase;
-use Drupal\facets\Processor\WidgetOrderProcessorInterface;
 use Drupal\facets\Result\Result;
+use Drupal\facets\SortProcessor\SortProcessorPluginBase;
 
 /**
  * A processor that orders the results by active state.
  *
- * @FacetsProcessor(
+ * @FacetsSortProcessor(
  *   id = "active_widget_order",
  *   label = @Translation("Sort by active state"),
  *   description = @Translation("Sorts the widget results by active state."),
@@ -24,20 +22,20 @@ use Drupal\facets\Result\Result;
  *   }
  * )
  */
-class ActiveWidgetOrderProcessor extends WidgetOrderPluginBase implements WidgetOrderProcessorInterface {
+class ActiveWidgetOrderProcessor extends SortProcessorPluginBase {
 
   /**
    * {@inheritdoc}
    */
-  public function sortResults(array $results, $order = 'ASC') {
+  public function sortResults(Result $a, Result $b) {
+
+    $order = $this->getConfiguration()['sort'];
+
     if ($order === 'ASC') {
-      usort($results, 'self::sortActiveAsc');
-    }
-    else {
-      usort($results, 'self::sortActiveDesc');
+      return self::sortActiveAsc($a, $b);
     }
 
-    return $results;
+    return self::sortActiveDesc($a, $b);
   }
 
   /**
diff --git a/src/Plugin/facets/processor/CountWidgetOrderProcessor.php b/src/Plugin/facets/sort_processor/CountWidgetOrderProcessor.php
similarity index 60%
rename from src/Plugin/facets/processor/CountWidgetOrderProcessor.php
rename to src/Plugin/facets/sort_processor/CountWidgetOrderProcessor.php
index f28f71b..8336665 100644
--- a/src/Plugin/facets/processor/CountWidgetOrderProcessor.php
+++ b/src/Plugin/facets/sort_processor/CountWidgetOrderProcessor.php
@@ -2,19 +2,18 @@
 
 /**
  * @file
- * Contains \Drupal\facets\Plugin\facets\processor\CountWidgetOrderProcessor.
+ * Contains \Drupal\facets\Plugin\facets\sort_processor\CountWidgetOrderProcessor.
  */
 
-namespace Drupal\facets\Plugin\facets\processor;
+namespace Drupal\facets\Plugin\facets\sort_processor;
 
-use Drupal\facets\Processor\WidgetOrderPluginBase;
-use Drupal\facets\Processor\WidgetOrderProcessorInterface;
 use Drupal\facets\Result\Result;
+use Drupal\facets\SortProcessor\SortProcessorPluginBase;
 
 /**
  * A processor that orders the results by amount.
  *
- * @FacetsProcessor(
+ * @FacetsSortProcessor(
  *   id = "count_widget_order",
  *   label = @Translation("Sort by count"),
  *   description = @Translation("Sorts the widget results by count."),
@@ -23,20 +22,20 @@ use Drupal\facets\Result\Result;
  *   }
  * )
  */
-class CountWidgetOrderProcessor extends WidgetOrderPluginBase implements WidgetOrderProcessorInterface {
+class CountWidgetOrderProcessor extends SortProcessorPluginBase {
 
   /**
    * {@inheritdoc}
    */
-  public function sortResults(array $results, $order = 'ASC') {
+  public function sortResults(Result $a, Result $b) {
+
+    $order = $this->getConfiguration()['sort'];
+
     if ($order === 'ASC') {
-      usort($results, 'self::sortCountAsc');
-    }
-    else {
-      usort($results, 'self::sortCountDesc');
+      return self::sortCountAsc($a, $b);
     }
 
-    return $results;
+    return self::sortCountDesc($a, $b);
   }
 
   /**
diff --git a/src/Plugin/facets/processor/DisplayValueWidgetOrderProcessor.php b/src/Plugin/facets/sort_processor/DisplayValueWidgetOrderProcessor.php
similarity index 57%
rename from src/Plugin/facets/processor/DisplayValueWidgetOrderProcessor.php
rename to src/Plugin/facets/sort_processor/DisplayValueWidgetOrderProcessor.php
index 638ad73..00be9cb 100644
--- a/src/Plugin/facets/processor/DisplayValueWidgetOrderProcessor.php
+++ b/src/Plugin/facets/sort_processor/DisplayValueWidgetOrderProcessor.php
@@ -2,19 +2,18 @@
 
 /**
  * @file
- * Contains \Drupal\facets\Plugin\facets\processor\DisplayValueWidgetOrderProcessor.
+ * Contains \Drupal\facets\Plugin\facets\sort_processor\DisplayValueWidgetOrderProcessor.
  */
 
-namespace Drupal\facets\Plugin\facets\processor;
+namespace Drupal\facets\Plugin\facets\sort_processor;
 
-use Drupal\facets\Processor\WidgetOrderPluginBase;
-use Drupal\facets\Processor\WidgetOrderProcessorInterface;
 use Drupal\facets\Result\Result;
+use Drupal\facets\SortProcessor\SortProcessorPluginBase;
 
 /**
  * A processor that orders the results by display value.
  *
- * @FacetsProcessor(
+ * @FacetsSortProcessor(
  *   id = "display_value_widget_order",
  *   label = @Translation("Sort by display value"),
  *   description = @Translation("Sorts the widget results by display value."),
@@ -23,20 +22,20 @@ use Drupal\facets\Result\Result;
  *   }
  * )
  */
-class DisplayValueWidgetOrderProcessor extends WidgetOrderPluginBase implements WidgetOrderProcessorInterface {
+class DisplayValueWidgetOrderProcessor extends SortProcessorPluginBase {
 
   /**
    * {@inheritdoc}
    */
-  public function sortResults(array $results, $order = 'ASC') {
+  public function sortResults(Result $a, Result $b) {
+
+    $order = $this->getConfiguration()['sort'];
+
     if ($order === 'ASC') {
-      usort($results, 'self::sortDisplayValueAsc');
-    }
-    else {
-      usort($results, 'self::sortDisplayValueDesc');
+      return self::sortDisplayValueAsc($a, $b);
     }
 
-    return $results;
+    return self::sortDisplayValueDesc($a, $b);
   }
 
   /**
diff --git a/src/Plugin/facets/processor/RawValueWidgetOrderProcessor.php b/src/Plugin/facets/sort_processor/RawValueWidgetOrderProcessor.php
similarity index 56%
rename from src/Plugin/facets/processor/RawValueWidgetOrderProcessor.php
rename to src/Plugin/facets/sort_processor/RawValueWidgetOrderProcessor.php
index f5c9787..87600ec 100644
--- a/src/Plugin/facets/processor/RawValueWidgetOrderProcessor.php
+++ b/src/Plugin/facets/sort_processor/RawValueWidgetOrderProcessor.php
@@ -2,19 +2,18 @@
 
 /**
  * @file
- * Contains \Drupal\facets\Plugin\facets\processor\RawValueWidgetOrderProcessor.
+ * Contains \Drupal\facets\Plugin\facets\sort_processor\RawValueWidgetOrderProcessor.
  */
 
-namespace Drupal\facets\Plugin\facets\processor;
+namespace Drupal\facets\Plugin\facets\sort_processor;
 
-use Drupal\facets\Processor\WidgetOrderPluginBase;
-use Drupal\facets\Processor\WidgetOrderProcessorInterface;
 use Drupal\facets\Result\Result;
+use Drupal\facets\SortProcessor\SortProcessorPluginBase;
 
 /**
  * A processor that orders the results by raw value.
  *
- * @FacetsProcessor(
+ * @FacetsSortProcessor(
  *   id = "raw_value_widget_order",
  *   label = @Translation("Sort by raw value"),
  *   description = @Translation("Sorts the widget results by raw value."),
@@ -23,20 +22,20 @@ use Drupal\facets\Result\Result;
  *   }
  * )
  */
-class RawValueWidgetOrderProcessor extends WidgetOrderPluginBase implements WidgetOrderProcessorInterface {
+class RawValueWidgetOrderProcessor extends SortProcessorPluginBase {
 
   /**
    * {@inheritdoc}
    */
-  public function sortResults(array $results, $order = 'ASC') {
+  public function sortResults(Result $a, Result $b) {
+
+    $order = $this->getConfiguration()['sort'];
+
     if ($order === 'ASC') {
-      usort($results, 'self::sortRawValueAsc');
-    }
-    else {
-      usort($results, 'self::sortRawValueDesc');
+      return self::sortRawValueAsc($a, $b);
     }
 
-    return $results;
+    return self::sortRawValueDesc($a, $b);
   }
 
   /**
diff --git a/src/Processor/WidgetOrderProcessorInterface.php b/src/Processor/WidgetOrderProcessorInterface.php
deleted file mode 100644
index fadab54..0000000
--- a/src/Processor/WidgetOrderProcessorInterface.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\facets\Processor\WidgetOrderProcessorInterface.
- */
-
-namespace Drupal\facets\Processor;
-
-/**
- * Processor runs before the renderable array is created.
- */
-interface WidgetOrderProcessorInterface extends BuildProcessorInterface {
-
-  /**
-   * Orders results and return the new order of results.
-   *
-   * @param \Drupal\facets\Result\Result[] $results
-   *   An array containing results.
-   * @param string $order
-   *   A string denoting the order in which we should sort, either 'ASC' or
-   *   'DESC'.
-   *
-   * @return \Drupal\facets\Result\Result[]
-   *   The same array that was passed in, ordered by $order
-   */
-  public function sortResults(array $results, $order = 'ASC');
-
-}
diff --git a/src/SortProcessor/SortProcessorInterface.php b/src/SortProcessor/SortProcessorInterface.php
new file mode 100644
index 0000000..fcd4e56
--- /dev/null
+++ b/src/SortProcessor/SortProcessorInterface.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * @file
+ * Contains Drupal\facets\SortProcessor\SortProcessorInterface.
+ */
+
+namespace Drupal\facets\SortProcessor;
+
+use Drupal\facets\Result\Result;
+
+/**
+ * Interface SortProcessorInterface.
+ *
+ * The url processor takes care of retrieving facet information from the url.
+ * It also handles the generation of facet links. This extends the pre query and
+ * build processor interfaces, those methods are where the bulk of the work
+ * should be done.
+ */
+interface SortProcessorInterface {
+
+
+  /**
+   * Compares results and returns the result for uasort().
+   *
+   * @param \Drupal\facets\Result\Result $a
+   *   An array containing results.
+   * @param \Drupal\facets\Result\Result $b
+   *   Second result item for comparison.
+   *
+   * @return int
+   *   The comparison result for uasort().
+   */
+  public function sortResults(Result $a, Result $b);
+
+}
diff --git a/src/Processor/WidgetOrderPluginBase.php b/src/SortProcessor/SortProcessorPluginBase.php
similarity index 57%
rename from src/Processor/WidgetOrderPluginBase.php
rename to src/SortProcessor/SortProcessorPluginBase.php
index 3aac26a..74b1afc 100644
--- a/src/Processor/WidgetOrderPluginBase.php
+++ b/src/SortProcessor/SortProcessorPluginBase.php
@@ -2,18 +2,19 @@
 
 /**
  * @file
- * Contains \Drupal\facets\Processor\WidgetOrderPluginBase.
+ * Contains \Drupal\facets\SortProcessor\SortProcessorPluginBase.
  */
 
-namespace Drupal\facets\Processor;
+namespace Drupal\facets\SortProcessor;
 
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\facets\FacetInterface;
+use Drupal\facets\Processor\ProcessorPluginBase;
 
 /**
- * A base class for plugins that implements some boilerplate for a widget order.
+ * A base class for plugins that implements boilerplate for a sort processor.
  */
-abstract class WidgetOrderPluginBase extends ProcessorPluginBase implements WidgetOrderProcessorInterface {
+abstract class SortProcessorPluginBase extends ProcessorPluginBase implements SortProcessorInterface {
 
   /**
    * {@inheritdoc}
@@ -38,17 +39,6 @@ abstract class WidgetOrderPluginBase extends ProcessorPluginBase implements Widg
   /**
    * {@inheritdoc}
    */
-  public function build(FacetInterface $facet, array $results) {
-    $processors = $facet->getProcessors();
-    $config = $processors[$this->getPluginId()];
-
-    // This should load the facet's config to find the ordering direction.
-    return $this->sortResults($results, $config->getConfiguration()['sort']);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
   public function defaultConfiguration() {
     return ['sort' => 'ASC'];
   }
diff --git a/src/SortProcessor/SortProcessorPluginManager.php b/src/SortProcessor/SortProcessorPluginManager.php
new file mode 100644
index 0000000..fc83cfb
--- /dev/null
+++ b/src/SortProcessor/SortProcessorPluginManager.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\facets\SortProcessor\SortProcessorPluginManager.
+ */
+
+namespace Drupal\facets\SortProcessor;
+
+use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Plugin\DefaultPluginManager;
+
+/**
+ * Manages URL processor plugins.
+ *
+ * @see \Drupal\facets\Annotation\FacetsProcessor
+ * @see \Drupal\facets\Processor\ProcessorInterface
+ * @see \Drupal\facets\Processor\ProcessorPluginBase
+ * @see plugin_api
+ */
+class SortProcessorPluginManager extends DefaultPluginManager {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
+    parent::__construct('Plugin/facets/sort_processor', $namespaces, $module_handler, 'Drupal\facets\SortProcessor\SortProcessorInterface', 'Drupal\facets\Annotation\FacetsSortProcessor');
+    $this->setCacheBackend($cache_backend, 'facets_sort_processors');
+  }
+
+}
diff --git a/src/Tests/ProcessorIntegrationTest.php b/src/Tests/ProcessorIntegrationTest.php
index 365686d..48774cf 100644
--- a/src/Tests/ProcessorIntegrationTest.php
+++ b/src/Tests/ProcessorIntegrationTest.php
@@ -138,6 +138,87 @@ class ProcessorIntegrationTest extends FacetWebTestBase {
   }
 
   /**
+   * Tests sorting of results.
+   */
+  public function testResultSorting() {
+    $id = 'burrowing_owl';
+    $name = 'Burrowing owl';
+
+    $this->createFacet($name, $id, 'keywords');
+    $this->createFacetBlock($id);
+
+    $values = [
+      'facet_sorting[display_value_widget_order][status]' => TRUE,
+      'widget_configs[show_numbers]' => TRUE,
+    ];
+    $this->drupalGet('admin/config/search/facets/' . $id . '/display');
+    $this->drupalPostForm(NULL, $values, $this->t('Save'));
+
+    $expected_results = [
+      'apple (4)',
+      'banana (2)',
+      'grape (6)',
+      'orange (6)',
+      'strawberry (4)',
+    ];
+
+    $this->drupalGet('search-api-test-fulltext');
+    foreach ($expected_results as $k => $link) {
+      if ($k > 0) {
+        $x = $expected_results[($k - 1)];
+        $y = $expected_results[$k];
+        $this->assertStringPosition($x, $y);
+      }
+    }
+
+    $values['facet_sorting[display_value_widget_order][status]'] = FALSE;
+    $values['facet_sorting[count_widget_order][status]'] = TRUE;
+    $this->drupalGet('admin/config/search/facets/' . $id . '/display');
+    $this->drupalPostForm(NULL, $values, $this->t('Save'));
+
+    $expected_results = [
+      'banana (2)',
+      'apple (4)',
+      'strawberry (4)',
+      'grape (6)',
+      'orange (6)',
+    ];
+
+    $this->drupalGet('search-api-test-fulltext');
+    foreach ($expected_results as $k => $link) {
+      if ($k > 0) {
+        $x = $expected_results[($k - 1)];
+        $y = $expected_results[$k];
+        $this->assertStringPosition($x, $y);
+      }
+    }
+
+    $values['facet_sorting[display_value_widget_order][status]'] = TRUE;
+    $values['facet_sorting[count_widget_order][status]'] = TRUE;
+    $this->drupalGet('admin/config/search/facets/' . $id . '/display');
+    $this->drupalPostForm(NULL, $values, $this->t('Save'));
+    $this->assertFieldChecked('edit-facet-sorting-display-value-widget-order-status');
+    $this->assertFieldChecked('edit-facet-sorting-count-widget-order-status');
+
+    $expected_results = [
+      'banana (2)',
+      'apple (4)',
+      'strawberry (4)',
+      'grape (6)',
+      'orange (6)',
+    ];
+
+    $this->drupalGet('search-api-test-fulltext');
+    foreach ($expected_results as $k => $link) {
+      if ($k > 0) {
+        $x = $expected_results[($k - 1)];
+        $y = $expected_results[$k];
+        $this->assertStringPosition($x, $y);
+      }
+    }
+  }
+
+  /**
    * Tests the count limit processor.
    */
   private function checkCountLimitProcessor() {
diff --git a/tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php
deleted file mode 100644
index 5da0b37..0000000
--- a/tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\facets\Plugin\Processor\ActiveWidgetOrderProcessorTest.
- */
-
-namespace Drupal\Tests\facets\Unit\Plugin\processor;
-
-use Drupal\facets\Entity\Facet;
-use Drupal\facets\Plugin\facets\processor\ActiveWidgetOrderProcessor;
-use Drupal\facets\Processor\ProcessorPluginManager;
-use Drupal\facets\Result\Result;
-use Drupal\Tests\UnitTestCase;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-
-/**
- * Unit test for processor.
- *
- * @group facets
- */
-class ActiveWidgetOrderProcessorTest extends UnitTestCase {
-
-  /**
-   * The processor to be tested.
-   *
-   * @var \Drupal\facets\processor\WidgetOrderProcessorInterface
-   */
-  protected $processor;
-
-  /**
-   * An array containing the results before the processor has ran.
-   *
-   * @var \Drupal\facets\Result\Result[]
-   */
-  protected $originalResults;
-
-  /**
-   * Creates a new processor object for use in the tests.
-   */
-  protected function setUp() {
-    parent::setUp();
-
-    /** @var \Drupal\facets\Result\Result[] $original_results */
-    $original_results = [
-      new Result('Boxer', 'Boxer', 10),
-      new Result('Old Major', 'Old Major', 3),
-      new Result('Minimus', 'Minimus', 60),
-      new Result('Mr Whymper', 'Mr. Whymper', 1),
-      new Result('Clover', 'Clover', 50),
-    ];
-
-    $original_results[1]->setActiveState(TRUE);
-    $original_results[2]->setActiveState(TRUE);
-    $original_results[3]->setActiveState(TRUE);
-
-    $this->originalResults = $original_results;
-
-    $this->processor = new ActiveWidgetOrderProcessor([], 'active_widget_order', []);
-  }
-
-  /**
-   * Tests sorting ascending.
-   */
-  public function testAscending() {
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
-    $expected_values = [TRUE, TRUE, TRUE, FALSE, FALSE];
-    foreach ($expected_values as $index => $value) {
-      $this->assertEquals($value, $sorted_results[$index]->isActive());
-    }
-  }
-
-  /**
-   * Tests sorting descending.
-   */
-  public function testDescending() {
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
-    $expected_values = array_reverse([TRUE, TRUE, TRUE, FALSE, FALSE]);
-    foreach ($expected_values as $index => $value) {
-      $this->assertEquals($value, $sorted_results[$index]->isActive());
-    }
-  }
-
-  /**
-   * Tests configuration.
-   */
-  public function testConfiguration() {
-    $config = $this->processor->defaultConfiguration();
-    $this->assertEquals(['sort' => 'ASC'], $config);
-  }
-
-  /**
-   * Tests build.
-   */
-  public function testBuild() {
-    $processor_definitions = [
-      'active_widget_order' => [
-        'id' => 'active_widget_order',
-        'class' => 'Drupal\facets\Plugin\facets\processor\ActiveWidgetOrderProcessor',
-      ],
-    ];
-    $manager = $this->getMockBuilder(ProcessorPluginManager::class)
-      ->disableOriginalConstructor()
-      ->getMock();
-    $manager->expects($this->once())
-      ->method('getDefinitions')
-      ->willReturn($processor_definitions);
-    $manager->expects($this->once())
-      ->method('createInstance')
-      ->willReturn($this->processor);
-
-    $container_builder = new ContainerBuilder();
-    $container_builder->set('plugin.manager.facets.processor', $manager);
-    \Drupal::setContainer($container_builder);
-
-    $facet = new Facet(
-      [
-        'id' => 'the_zoo',
-        'results' => $this->originalResults,
-        'processor_configs' => $processor_definitions,
-      ],
-      'facets_facet'
-    );
-    $built = $this->processor->build($facet, $this->originalResults);
-
-    $this->assertEquals(TRUE, $built[0]->isActive());
-    $this->assertEquals(TRUE, $built[1]->isActive());
-    $this->assertEquals(TRUE, $built[2]->isActive());
-    $this->assertEquals(FALSE, $built[3]->isActive());
-    $this->assertEquals(FALSE, $built[4]->isActive());
-  }
-
-}
diff --git a/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
deleted file mode 100644
index 7adeec1..0000000
--- a/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\facets\Plugin\Processor\CountWidgetOrderProcessorTest.
- */
-
-namespace Drupal\Tests\facets\Unit\Plugin\processor;
-
-use Drupal\facets\Entity\Facet;
-use Drupal\facets\Plugin\facets\processor\CountWidgetOrderProcessor;
-use Drupal\facets\Processor\ProcessorPluginManager;
-use Drupal\facets\Result\Result;
-use Drupal\Tests\UnitTestCase;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-
-/**
- * Unit test for processor.
- *
- * @group facets
- */
-class CountWidgetOrderProcessorTest extends UnitTestCase {
-
-  /**
-   * The processor to be tested.
-   *
-   * @var \Drupal\facets\processor\WidgetOrderProcessorInterface
-   */
-  protected $processor;
-
-  /**
-   * An array containing the results before the processor has ran.
-   *
-   * @var \Drupal\facets\Result\Result[]
-   */
-  protected $originalResults;
-
-  /**
-   * Creates a new processor object for use in the tests.
-   */
-  protected function setUp() {
-    parent::setUp();
-
-    $this->originalResults = [
-      new Result('llama', 'llama', 10),
-      new Result('badger', 'badger', 5),
-      new Result('duck', 'duck', 15),
-    ];
-
-    $this->processor = new CountWidgetOrderProcessor([], 'count_widget_order', []);
-  }
-
-  /**
-   * Tests sorting ascending.
-   */
-  public function testAscending() {
-
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
-
-    $this->assertEquals(5, $sorted_results[0]->getCount());
-    $this->assertEquals('badger', $sorted_results[0]->getDisplayValue());
-    $this->assertEquals(10, $sorted_results[1]->getCount());
-    $this->assertEquals('llama', $sorted_results[1]->getDisplayValue());
-    $this->assertEquals(15, $sorted_results[2]->getCount());
-    $this->assertEquals('duck', $sorted_results[2]->getDisplayValue());
-  }
-
-  /**
-   * Tests sorting descending.
-   */
-  public function testDescending() {
-
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
-
-    $this->assertEquals(15, $sorted_results[0]->getCount());
-    $this->assertEquals('duck', $sorted_results[0]->getDisplayValue());
-    $this->assertEquals(10, $sorted_results[1]->getCount());
-    $this->assertEquals('llama', $sorted_results[1]->getDisplayValue());
-    $this->assertEquals(5, $sorted_results[2]->getCount());
-    $this->assertEquals('badger', $sorted_results[2]->getDisplayValue());
-  }
-
-  /**
-   * Tests configuration.
-   */
-  public function testConfiguration() {
-    $config = $this->processor->defaultConfiguration();
-    $this->assertEquals(['sort' => 'ASC'], $config);
-  }
-
-  /**
-   * Tests build.
-   */
-  public function testBuild() {
-    $processor_definitions = [
-      'count_widget_order' => [
-        'id' => 'count_widget_order',
-        'class' => 'Drupal\facets\Plugin\facets\processor\CountWidgetOrderProcessor',
-      ],
-    ];
-    $manager = $this->getMockBuilder(ProcessorPluginManager::class)
-      ->disableOriginalConstructor()
-      ->getMock();
-    $manager->expects($this->once())
-      ->method('getDefinitions')
-      ->willReturn($processor_definitions);
-    $manager->expects($this->once())
-      ->method('createInstance')
-      ->willReturn($this->processor);
-
-    $container_builder = new ContainerBuilder();
-    $container_builder->set('plugin.manager.facets.processor', $manager);
-    \Drupal::setContainer($container_builder);
-
-    $facet = new Facet(
-      [
-        'id' => 'the_zoo',
-        'results' => $this->originalResults,
-        'processor_configs' => $processor_definitions,
-      ],
-      'facets_facet'
-    );
-    $built = $this->processor->build($facet, $this->originalResults);
-
-    $this->assertEquals('badger', $built[0]->getDisplayValue());
-    $this->assertEquals('llama', $built[1]->getDisplayValue());
-    $this->assertEquals('duck', $built[2]->getDisplayValue());
-  }
-
-}
diff --git a/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
deleted file mode 100644
index 7609dca..0000000
--- a/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
+++ /dev/null
@@ -1,162 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\facets\Plugin\Processor\DisplayValueWidgetOrderProcessorTest.
- */
-
-namespace Drupal\Tests\facets\Unit\Plugin\processor;
-
-use Drupal\facets\Entity\Facet;
-use Drupal\facets\Plugin\facets\processor\DisplayValueWidgetOrderProcessor;
-use Drupal\facets\Processor\ProcessorPluginManager;
-use Drupal\facets\Result\Result;
-use Drupal\Tests\UnitTestCase;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-
-/**
- * Unit test for processor.
- *
- * @group facets
- */
-class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
-
-  /**
-   * The processor to be tested.
-   *
-   * @var \Drupal\facets\processor\WidgetOrderProcessorInterface
-   */
-  protected $processor;
-
-  /**
-   * An array containing the results before the processor has ran.
-   *
-   * @var \Drupal\facets\Result\Result[]
-   */
-  protected $originalResults;
-
-  /**
-   * Creates a new processor object for use in the tests.
-   */
-  protected function setUp() {
-    parent::setUp();
-
-    $this->originalResults = [
-      new Result('thetans', 'thetans', 10),
-      new Result('xenu', 'xenu', 5),
-      new Result('Tom', 'Tom', 15),
-      new Result('Hubbard', 'Hubbard', 666),
-      new Result('FALSE', 'FALSE', 1),
-      new Result('1977', '1977', 20),
-      new Result('2', '2', 22),
-    ];
-
-    $this->processor = new DisplayValueWidgetOrderProcessor([], 'display_value_widget_order', []);
-  }
-
-  /**
-   * Tests sorting ascending.
-   */
-  public function testAscending() {
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
-    $expected_values = [
-      '2',
-      '1977',
-      'FALSE',
-      'Hubbard',
-      'thetans',
-      'Tom',
-      'xenu',
-    ];
-    foreach ($expected_values as $index => $value) {
-      $this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
-    }
-  }
-
-  /**
-   * Tests sorting descending.
-   */
-  public function testDescending() {
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
-    $expected_values = array_reverse([
-      '2',
-      '1977',
-      'FALSE',
-      'Hubbard',
-      'thetans',
-      'Tom',
-      'xenu',
-    ]);
-    foreach ($expected_values as $index => $value) {
-      $this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
-    }
-  }
-
-  /**
-   * Tests that sorting uses the display value.
-   */
-  public function testUseActualDisplayValue() {
-    $original = [
-      new Result('bb_test', 'Test AA', 10),
-      new Result('aa_test', 'Test BB', 10),
-    ];
-
-    $sorted_results = $this->processor->sortResults($original, 'DESC');
-
-    $this->assertEquals('Test BB', $sorted_results[0]->getDisplayValue());
-    $this->assertEquals('Test AA', $sorted_results[1]->getDisplayValue());
-  }
-
-  /**
-   * Tests configuration.
-   */
-  public function testConfiguration() {
-    $config = $this->processor->defaultConfiguration();
-    $this->assertEquals(['sort' => 'ASC'], $config);
-  }
-
-
-  /**
-   * Tests build.
-   */
-  public function testBuild() {
-    $processor_definitions = [
-      'display_value_widget_order' => [
-        'id' => 'display_value_widget_order',
-        'class' => 'Drupal\facets\Plugin\facets\processor\DisplayValueWidgetOrderProcessor',
-      ],
-    ];
-    $manager = $this->getMockBuilder(ProcessorPluginManager::class)
-      ->disableOriginalConstructor()
-      ->getMock();
-    $manager->expects($this->once())
-      ->method('getDefinitions')
-      ->willReturn($processor_definitions);
-    $manager->expects($this->once())
-      ->method('createInstance')
-      ->willReturn($this->processor);
-
-    $container_builder = new ContainerBuilder();
-    $container_builder->set('plugin.manager.facets.processor', $manager);
-    \Drupal::setContainer($container_builder);
-
-    $facet = new Facet(
-      [
-        'id' => 'the_zoo',
-        'results' => $this->originalResults,
-        'processor_configs' => $processor_definitions,
-      ],
-      'facets_facet'
-    );
-    $built = $this->processor->build($facet, $this->originalResults);
-
-    $this->assertEquals('2', $built[0]->getDisplayValue());
-    $this->assertEquals('1977', $built[1]->getDisplayValue());
-    $this->assertEquals('FALSE', $built[2]->getDisplayValue());
-    $this->assertEquals('Hubbard', $built[3]->getDisplayValue());
-    $this->assertEquals('thetans', $built[4]->getDisplayValue());
-    $this->assertEquals('Tom', $built[5]->getDisplayValue());
-    $this->assertEquals('xenu', $built[6]->getDisplayValue());
-  }
-
-}
diff --git a/tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php
deleted file mode 100644
index ffd5a6e..0000000
--- a/tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\facets\Plugin\Processor\RawValueWidgetOrderProcessorTest.
- */
-
-namespace Drupal\Tests\facets\Unit\Plugin\processor;
-
-use Drupal\facets\Entity\Facet;
-use Drupal\facets\Plugin\facets\processor\RawValueWidgetOrderProcessor;
-use Drupal\facets\Processor\ProcessorPluginManager;
-use Drupal\facets\Result\Result;
-use Drupal\Tests\UnitTestCase;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-
-/**
- * Unit test for processor.
- *
- * @group facets
- */
-class RawValueWidgetOrderProcessorTest extends UnitTestCase {
-
-  /**
-   * The processor to be tested.
-   *
-   * @var \Drupal\facets\processor\WidgetOrderProcessorInterface
-   */
-  protected $processor;
-
-  /**
-   * An array containing the results before the processor has ran.
-   *
-   * @var \Drupal\facets\Result\Result[]
-   */
-  protected $originalResults;
-
-  /**
-   * Creates a new processor object for use in the tests.
-   */
-  protected function setUp() {
-    parent::setUp();
-
-    $this->originalResults = [
-      new Result('C', 'thetans', 10),
-      new Result('B', 'xenu', 5),
-      new Result('A', 'Tom', 15),
-      new Result('D', 'Hubbard', 666),
-      new Result('E', 'FALSE', 1),
-      new Result('G', '1977', 20),
-      new Result('F', '2', 22),
-    ];
-
-    $this->processor = new RawValueWidgetOrderProcessor([], 'raw_value_widget_order', []);
-  }
-
-  /**
-   * Tests sorting ascending.
-   */
-  public function testAscending() {
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
-    $expected_values = [
-      'Tom',
-      'xenu',
-      'thetans',
-      'Hubbard',
-      'FALSE',
-      '2',
-      '1977',
-    ];
-    foreach ($expected_values as $index => $value) {
-      $this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
-    }
-  }
-
-  /**
-   * Tests sorting descending.
-   */
-  public function testDescending() {
-    $sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
-    $expected_values = array_reverse([
-      'Tom',
-      'xenu',
-      'thetans',
-      'Hubbard',
-      'FALSE',
-      '2',
-      '1977',
-    ]);
-    foreach ($expected_values as $index => $value) {
-      $this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
-    }
-  }
-
-  /**
-   * Tests configuration.
-   */
-  public function testConfiguration() {
-    $config = $this->processor->defaultConfiguration();
-    $this->assertEquals(['sort' => 'ASC'], $config);
-  }
-
-  /**
-   * Tests build.
-   */
-  public function testBuild() {
-    $processor_definitions = [
-      'raw_value_widget_order' => [
-        'id' => 'raw_value_widget_order',
-        'class' => 'Drupal\facets\Plugin\facets\processor\RawValueWidgetOrderProcessor',
-      ],
-    ];
-    $manager = $this->getMockBuilder(ProcessorPluginManager::class)
-      ->disableOriginalConstructor()
-      ->getMock();
-    $manager->expects($this->once())
-      ->method('getDefinitions')
-      ->willReturn($processor_definitions);
-    $manager->expects($this->once())
-      ->method('createInstance')
-      ->willReturn($this->processor);
-
-    $container_builder = new ContainerBuilder();
-    $container_builder->set('plugin.manager.facets.processor', $manager);
-    \Drupal::setContainer($container_builder);
-
-    $facet = new Facet(
-      [
-        'id' => 'the_zoo',
-        'results' => $this->originalResults,
-        'processor_configs' => $processor_definitions,
-      ],
-      'facets_facet'
-    );
-    $built = $this->processor->build($facet, $this->originalResults);
-
-    $this->assertEquals('Tom', $built[0]->getDisplayValue());
-    $this->assertEquals('xenu', $built[1]->getDisplayValue());
-    $this->assertEquals('thetans', $built[2]->getDisplayValue());
-    $this->assertEquals('Hubbard', $built[3]->getDisplayValue());
-    $this->assertEquals('FALSE', $built[4]->getDisplayValue());
-    $this->assertEquals('2', $built[5]->getDisplayValue());
-    $this->assertEquals('1977', $built[6]->getDisplayValue());
-  }
-
-}
diff --git a/tests/src/Unit/Plugin/processor/SortProcessorHandlerTest.php b/tests/src/Unit/Plugin/processor/SortProcessorHandlerTest.php
new file mode 100644
index 0000000..9745315
--- /dev/null
+++ b/tests/src/Unit/Plugin/processor/SortProcessorHandlerTest.php
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\facets\Plugin\processor\SortProcessorHandlerTest.
+ */
+
+namespace Drupal\Tests\facets\Unit\Plugin\processor;
+
+use Drupal\facets\Entity\Facet;
+use Drupal\facets\Plugin\facets\processor\SortProcessorHandler;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Unit test for processor.
+ *
+ * @group facets
+ */
+class SortProcessorHandlerTest extends UnitTestCase {
+
+  /**
+   * Tests that the processor correctly throws an exception.
+   */
+  public function testEmptyProcessorConfiguration() {
+    $this->setExpectedException('\Drupal\facets\Exception\InvalidProcessorException', "The SortProcessorHandler doesn't have the required 'facet' in the configuration array.");
+    new SortProcessorHandler([], 'test', []);
+  }
+
+  /**
+   * Tests that the processor correctly throws an exception.
+   */
+  public function testInvalidProcessorConfiguration() {
+    $this->setExpectedException('\Drupal\facets\Exception\InvalidProcessorException', "The SortProcessorHandler doesn't have the required 'facet' in the configuration array.");
+    new SortProcessorHandler(['facet' => new \stdClass()], 'test', []);
+  }
+
+  /**
+   * Tests configuration.
+   */
+  public function testConfiguration() {
+    $facet = new Facet([], 'facets_facet');
+    $processor = new SortProcessorHandler(['facet' => $facet], 'url_processor_handler', []);
+
+    $config = $processor->defaultConfiguration();
+    $this->assertEquals([], $config);
+  }
+
+  /**
+   * Tests testDescription().
+   */
+  public function testDescription() {
+    $facet = new Facet([], 'facets_facet');
+    $processor = new SortProcessorHandler(['facet' => $facet], 'url_processor_handler', []);
+
+    $this->assertEquals('', $processor->getDescription());
+  }
+
+  /**
+   * Tests isHidden().
+   */
+  public function testIsHidden() {
+    $facet = new Facet([], 'facets_facet');
+    $processor = new SortProcessorHandler(['facet' => $facet], 'url_processor_handler', []);
+
+    $this->assertEquals(FALSE, $processor->isHidden());
+  }
+
+  /**
+   * Tests isLocked().
+   */
+  public function testIsLocked() {
+    $facet = new Facet([], 'facets_facet');
+    $processor = new SortProcessorHandler(['facet' => $facet], 'url_processor_handler', []);
+
+    $this->assertEquals(FALSE, $processor->isLocked());
+  }
+
+}
diff --git a/tests/src/Unit/Plugin/sort_processor/ActiveWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/sort_processor/ActiveWidgetOrderProcessorTest.php
new file mode 100644
index 0000000..eadc149
--- /dev/null
+++ b/tests/src/Unit/Plugin/sort_processor/ActiveWidgetOrderProcessorTest.php
@@ -0,0 +1,90 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\facets\Plugin\Processor\ActiveWidgetOrderProcessorTest.
+ */
+
+namespace Drupal\Tests\facets\Unit\Plugin\sort_processor;
+
+use Drupal\Component\Render\FormattableMarkup;
+use Drupal\facets\Plugin\facets\sort_processor\ActiveWidgetOrderProcessor;
+use Drupal\facets\Result\Result;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Unit test for processor.
+ *
+ * @group facets
+ */
+class ActiveWidgetOrderProcessorTest extends UnitTestCase {
+
+  /**
+   * An array containing the results before the processor has ran.
+   *
+   * @var \Drupal\facets\Result\Result[]
+   */
+  protected $originalResults;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    /** @var \Drupal\facets\Result\Result[] $original_results */
+    $original_results = [
+      new Result('Boxer', 'Boxer', 10),
+      new Result('Old Major', 'Old Major', 3),
+      new Result('Minimus', 'Minimus', 60),
+      new Result('Mr Whymper', 'Mr. Whymper', 1),
+      new Result('Clover', 'Clover', 50),
+    ];
+
+    $original_results[1]->setActiveState(TRUE);
+    $original_results[2]->setActiveState(TRUE);
+    $original_results[3]->setActiveState(TRUE);
+
+    $this->originalResults = $original_results;
+  }
+
+  /**
+   * Tests sorting ascending.
+   */
+  public function testAscending() {
+    $processor = new ActiveWidgetOrderProcessor(['sort' => 'ASC'], 'active_widget_order', []);
+    $expected_values = [0, 1, 0, 0, -1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests sorting descending.
+   */
+  public function testDescending() {
+    $processor = new ActiveWidgetOrderProcessor(['sort' => 'DESC'], 'active_widget_order', []);
+    $expected_values = [0, -1, 0, 0, 1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests configuration.
+   */
+  public function testConfiguration() {
+    $processor = new ActiveWidgetOrderProcessor([], 'active_widget_order', []);
+    $config = $processor->defaultConfiguration();
+    $this->assertEquals(['sort' => 'ASC'], $config);
+  }
+
+}
diff --git a/tests/src/Unit/Plugin/sort_processor/CountWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/sort_processor/CountWidgetOrderProcessorTest.php
new file mode 100644
index 0000000..3786d83
--- /dev/null
+++ b/tests/src/Unit/Plugin/sort_processor/CountWidgetOrderProcessorTest.php
@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\facets\Plugin\Processor\CountWidgetOrderProcessorTest.
+ */
+
+namespace Drupal\Tests\facets\Unit\Plugin\sort_processor;
+
+use Drupal\Component\Render\FormattableMarkup;
+use Drupal\facets\Plugin\facets\sort_processor\CountWidgetOrderProcessor;
+use Drupal\facets\Result\Result;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Unit test for processor.
+ *
+ * @group facets
+ */
+class CountWidgetOrderProcessorTest extends UnitTestCase {
+
+  /**
+   * An array containing the results before the processor has ran.
+   *
+   * @var \Drupal\facets\Result\Result[]
+   */
+  protected $originalResults;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->originalResults = [
+      new Result('llama', 'llama', 10),
+      new Result('badger', 'badger', 5),
+      new Result('duck', 'duck', 15),
+    ];
+  }
+
+  /**
+   * Tests sorting ascending.
+   */
+  public function testAscending() {
+    $processor = new CountWidgetOrderProcessor(['sort' => 'ASC'], 'count_widget_order', []);
+    $expected_values = [0, 1, -1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests sorting descending.
+   */
+  public function testDescending() {
+    $processor = new CountWidgetOrderProcessor(['sort' => 'DESC'], 'count_widget_order', []);
+    $expected_values = [0, -1, 1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests configuration.
+   */
+  public function testConfiguration() {
+    $processor = new CountWidgetOrderProcessor([], 'count_widget_order', []);
+    $config = $processor->defaultConfiguration();
+    $this->assertEquals(['sort' => 'ASC'], $config);
+  }
+
+}
diff --git a/tests/src/Unit/Plugin/sort_processor/DisplayValueWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/sort_processor/DisplayValueWidgetOrderProcessorTest.php
new file mode 100644
index 0000000..449156f
--- /dev/null
+++ b/tests/src/Unit/Plugin/sort_processor/DisplayValueWidgetOrderProcessorTest.php
@@ -0,0 +1,99 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\facets\Plugin\Processor\DisplayValueWidgetOrderProcessorTest.
+ */
+
+namespace Drupal\Tests\facets\Unit\Plugin\processor;
+
+use Drupal\Component\Render\FormattableMarkup;
+use Drupal\facets\Plugin\facets\sort_processor\DisplayValueWidgetOrderProcessor;
+use Drupal\facets\Result\Result;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Unit test for processor.
+ *
+ * @group facets
+ */
+class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
+
+  /**
+   * An array containing the results before the processor has ran.
+   *
+   * @var \Drupal\facets\Result\Result[]
+   */
+  protected $originalResults;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->originalResults = [
+      new Result('thetans', 'thetans', 10),
+      new Result('xenu', 'xenu', 5),
+      new Result('Hubbard', 'Hubbard', 666),
+      new Result('Tom', 'Tom', 15),
+      new Result('FALSE', 'FALSE', 1),
+      new Result('2', '2', 22),
+      new Result('1977', '1977', 20),
+    ];
+  }
+
+  /**
+   * Tests sorting ascending.
+   */
+  public function testAscending() {
+    $processor = new DisplayValueWidgetOrderProcessor(['sort' => 'ASC'], 'display_value_widget_order', []);
+    $expected_values = [0, -1, 1, -1, 1, 1, -1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests sorting descending.
+   */
+  public function testDescending() {
+    $processor = new DisplayValueWidgetOrderProcessor(['sort' => 'DESC'], 'display_value_widget_order', []);
+    $expected_values = [0, 1, -1, 1, -1, -1, 1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests that sorting uses the display value.
+   */
+  public function testUseActualDisplayValue() {
+    $original = [
+      new Result('bb_test', 'Test AA', 10),
+      new Result('aa_test', 'Test BB', 10),
+    ];
+
+    $processor = new DisplayValueWidgetOrderProcessor(['sort' => 'DESC'], 'display_value_widget_order', []);
+    $result = $processor->sortResults($original[0], $original[1]);
+    $this->assertEquals(1, $result);
+  }
+
+  /**
+   * Tests configuration.
+   */
+  public function testConfiguration() {
+    $processor = new DisplayValueWidgetOrderProcessor([], 'display_value_widget_order', []);
+    $config = $processor->defaultConfiguration();
+    $this->assertEquals(['sort' => 'ASC'], $config);
+  }
+
+}
diff --git a/tests/src/Unit/Plugin/sort_processor/RawValueWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/sort_processor/RawValueWidgetOrderProcessorTest.php
new file mode 100644
index 0000000..2be23eb
--- /dev/null
+++ b/tests/src/Unit/Plugin/sort_processor/RawValueWidgetOrderProcessorTest.php
@@ -0,0 +1,85 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\facets\Plugin\Processor\RawValueWidgetOrderProcessorTest.
+ */
+
+namespace Drupal\Tests\facets\Unit\Plugin\processor;
+
+use Drupal\Component\Render\FormattableMarkup;
+use Drupal\facets\Plugin\facets\sort_processor\RawValueWidgetOrderProcessor;
+use Drupal\facets\Result\Result;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Unit test for processor.
+ *
+ * @group facets
+ */
+class RawValueWidgetOrderProcessorTest extends UnitTestCase {
+
+  /**
+   * An array containing the results before the processor has ran.
+   *
+   * @var \Drupal\facets\Result\Result[]
+   */
+  protected $originalResults;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->originalResults = [
+      new Result('C', 'thetans', 10),
+      new Result('B', 'xenu', 5),
+      new Result('A', 'Tom', 15),
+      new Result('D', 'Hubbard', 666),
+      new Result('E', 'FALSE', 1),
+      new Result('G', '1977', 20),
+      new Result('F', '2', 22),
+    ];
+  }
+
+  /**
+   * Tests sorting ascending.
+   */
+  public function testAscending() {
+    $processor = new RawValueWidgetOrderProcessor(['sort' => 'ASC'], 'raw_value_widget_order', []);
+    $expected_values = [0, 1, 1, -1, -1, -1, 1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests sorting descending.
+   */
+  public function testDescending() {
+    $processor = new RawValueWidgetOrderProcessor(['sort' => 'DESC'], 'raw_value_widget_order', []);
+    $expected_values = [0, -1, -1, 1, 1, 1, -1];
+    foreach ($expected_values as $index => $value) {
+      if ($index >= 1) {
+        $ua_result = $processor->sortResults($this->originalResults[$index - 1], $this->originalResults[$index]);
+        $message = new FormattableMarkup('Failed asserting uasort return value for :a and :b', [':a' => $this->originalResults[$index -1]->getDisplayValue(), ':b' => $this->originalResults[$index]->getDisplayValue()]);
+        $this->assertEquals($value, $ua_result, $message);
+      }
+    }
+  }
+
+  /**
+   * Tests configuration.
+   */
+  public function testConfiguration() {
+    $processor = new RawValueWidgetOrderProcessor([], 'raw_value_widget_order', []);
+    $config = $processor->defaultConfiguration();
+    $this->assertEquals(['sort' => 'ASC'], $config);
+  }
+
+}
