We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2a427f commit ea45962Copy full SHA for ea45962
crates/bevy_ecs/src/core/world.rs
@@ -236,12 +236,14 @@ impl World {
236
/// let a = world.spawn((123, true, "abc"));
237
/// let b = world.spawn((456, false));
238
/// let c = world.spawn((42, "def"));
239
- /// let entities = world.query::<(Entity, &i32, &bool)>()
+ /// let mut entities = world.query::<(Entity, &i32, &bool)>()
240
/// .map(|(e, &i, &b)| (e, i, b)) // Copy out of the world
241
/// .collect::<Vec<_>>();
242
+ /// // Sort by `i32` component in reverse and by `bool` then
243
+ /// entities.sort_by(|x, y| x.1.cmp(&y.1).reverse().then(x.2.cmp(&y.2)))
244
/// assert_eq!(entities.len(), 2);
- /// assert!(entities.contains(&(a, 123, true)));
- /// assert!(entities.contains(&(b, 456, false)));
245
+ /// assert!(entities[0] == (b, 456, false));
246
+ /// assert!(entities[1] == (a, 123, true));
247
/// ```
248
#[inline]
249
pub fn query<Q: WorldQuery>(&self) -> QueryIter<'_, Q, ()>
0 commit comments