diff --git a/core/modules/workflows/src/Plugin/WorkflowTypeBase.php b/core/modules/workflows/src/Plugin/WorkflowTypeBase.php
index b7e18d9dd9..7b47d9c484 100644
--- a/core/modules/workflows/src/Plugin/WorkflowTypeBase.php
+++ b/core/modules/workflows/src/Plugin/WorkflowTypeBase.php
@@ -281,15 +281,27 @@ public function getTransitions(array $transition_ids = NULL) {
    */
   protected static function labelWeightMultisort($objects) {
     if (count($objects) > 1) {
+      // Separate weights, labels, and keys into arrays.
       $weights = $labels = [];
+      $keys = array_keys($objects);
       foreach ($objects as $id => $object) {
         $weights[$id] = $object->weight();
         $labels[$id] = $object->label();
       }
+      // Sort weights, labels, and keys in the same order as each other.
       array_multisort(
-        $weights, SORT_NUMERIC, SORT_ASC,
-        $labels, SORT_NATURAL, SORT_ASC
+        $weights,
+        SORT_NUMERIC,
+        SORT_ASC,
+        $labels,
+        SORT_NATURAL,
+        SORT_ASC,
+        $keys
       );
+      // Combine keys and weights to make sure the weights are keyed with the
+      // correct keys.
+      $weights = array_combine($keys, $weights);
+      // Return the objects sorted by weight.
       return array_replace($weights, $objects);
     }
     return $objects;
diff --git a/core/modules/workflows/tests/src/Unit/WorkflowTest.php b/core/modules/workflows/tests/src/Unit/WorkflowTest.php
index ca76fa0ee1..a65a03266d 100644
--- a/core/modules/workflows/tests/src/Unit/WorkflowTest.php
+++ b/core/modules/workflows/tests/src/Unit/WorkflowTest.php
@@ -118,6 +118,27 @@ public function testGetStates() {
   }
 
   /**
+   * Test numeric IDs when added to a workflow.
+   */
+  public function testNumericIdSorting() {
+    $workflow = new Workflow(['id' => 'test', 'type' => 'test_type'], 'workflow');
+    $workflow_type = $workflow->getTypePlugin();
+
+    $workflow_type->addState('1', 'One');
+    $workflow_type->addState('2', 'Two');
+    $workflow_type->addState('3', 'ZZZ');
+    $workflow_type->addState('4', 'AAA');
+
+    $workflow_type->setStateWeight('1', 1);
+    $workflow_type->setStateWeight('2', 2);
+    $workflow_type->setStateWeight('3', 3);
+    $workflow_type->setStateWeight('4', 3);
+
+    // Ensure numeric states are correctly sorted by weight first, label second.
+    $this->assertEquals([1, 2, 4, 3], array_keys($workflow_type->getStates()));
+  }
+
+  /**
    * @covers ::getStates
    */
   public function testGetStatesException() {
