From eaa7dfedea342167da56db767684ff26b45cd8a6 Mon Sep 17 00:00:00 2001 From: Vic <59878206+Victoronz@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:24:35 +0100 Subject: [PATCH] fix QueryIter::sort_unstable_by (#16565) # Objective `QueryIter::sort_unstable_by` is mistakenly using `slice::sort_by`. ## Solution Use `slice::sort_unstable_by`. --- crates/bevy_ecs/src/query/iter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/query/iter.rs b/crates/bevy_ecs/src/query/iter.rs index bf4c5432546f9..cb1d695a4d58c 100644 --- a/crates/bevy_ecs/src/query/iter.rs +++ b/crates/bevy_ecs/src/query/iter.rs @@ -774,7 +774,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> { ) }; let mut keyed_query: Vec<_> = query_lens.collect(); - keyed_query.sort_by(|(key_1, _), (key_2, _)| compare(key_1, key_2)); + keyed_query.sort_unstable_by(|(key_1, _), (key_2, _)| compare(key_1, key_2)); let entity_iter = keyed_query.into_iter().map(|(.., entity)| entity); // SAFETY: // `self.world` has permission to access the required components.