diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 43427e2ebc7d6414744ab086909439f1a4b28a99..d75f7984e2c30253a4323ebf1fc440d9a55efa47 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -48,7 +48,7 @@ class CommitStatus < Ci::ApplicationRecord
   scope :ordered, -> { order(:name) }
   scope :ordered_by_stage, -> { order(stage_idx: :asc) }
   scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
-  scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
+  scope :retried_ordered, -> { retried.order(name: :asc, id: :desc).includes(project: :namespace) }
   scope :ordered_by_pipeline, -> { order(pipeline_id: :asc) }
   scope :before_stage, -> (index) { where('stage_idx < ?', index) }
   scope :for_stage, -> (index) { where(stage_idx: index) }
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 20afddd847004f5edd9fc2a71ce443d5b8d1aef0..59d14574c0218aa8961eb21663f47b44569e2a53 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -379,6 +379,22 @@ def create_build_with_set_timestamps(created_at:, updated_at:)
     end
   end
 
+  describe '.retried_ordered' do
+    subject { described_class.retried_ordered.to_a }
+
+    let!(:statuses) do
+      [create_status(name: 'aa', ref: 'bb', status: 'running', retried: true),
+       create_status(name: 'cc', ref: 'cc', status: 'pending', retried: true),
+       create_status(name: 'aa', ref: 'cc', status: 'success', retried: true),
+       create_status(name: 'cc', ref: 'bb', status: 'success'),
+       create_status(name: 'aa', ref: 'bb', status: 'success')]
+    end
+
+    it 'returns retried statuses in order' do
+      is_expected.to eq(statuses.values_at(2, 0, 1))
+    end
+  end
+
   describe '.running_or_pending' do
     subject { described_class.running_or_pending.order(:id) }