diff --git a/core/includes/common.inc b/core/includes/common.inc
index 61b63be..570fc2b 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -1,6 +1,7 @@
 <?php
 
 use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\SortArray;
 use Drupal\Component\Utility\String;
 use Drupal\Component\Utility\Tags;
 use Drupal\Component\Utility\UrlValidator;
@@ -5180,14 +5181,22 @@ function element_info_property($type, $property_name, $default = NULL) {
  *   element, a default value of 0 will be used.
  * @param $b
  *   Second item for comparison.
+ *
+ * @see \Drupal\Component\Utility\String::checkPlain()
+ *
+ * @deprecated
  */
 function drupal_sort_weight($a, $b) {
-  $a_weight = (is_array($a) && isset($a['weight'])) ? $a['weight'] : 0;
-  $b_weight = (is_array($b) && isset($b['weight'])) ? $b['weight'] : 0;
-  if ($a_weight == $b_weight) {
-    return 0;
+  // Ensure we're passing an array to SortArray::sortWeight. If we didn't get an array in the
+  // first place then passing an empty array in will have the same effect as $a['weight'] will
+  // not be set.
+  if (!is_array($a)) {
+    $a = array();
   }
-  return ($a_weight < $b_weight) ? -1 : 1;
+  if (!is_array($b)) {
+    $b = array();
+  }
+  return SortArray::sortWeight($a, $b);
 }
 
 /**
diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php
index b5a5f9c..1d58f3d 100644
--- a/core/lib/Drupal/Core/Entity/EntityListController.php
+++ b/core/lib/Drupal/Core/Entity/EntityListController.php
@@ -159,7 +159,7 @@ public function buildOperations(EntityInterface $entity) {
     // Retrieve and sort operations.
     $operations = $this->getOperations($entity);
     $this->moduleHandler->alter('entity_operation', $operations, $entity);
-    uasort($operations, 'drupal_sort_weight');
+    uasort($operations, array('Drupal\Component\Utility\SortArray', 'sortWeight'));
     $build = array(
       '#type' => 'operations',
       '#links' => $operations,
