bevy/tools
Vic b78efd339d
Simplify sort/max_by calls (#17048)
# Objective

Some sort calls and `Ord` impls are unnecessarily complex.

## Solution

Rewrite the "match on cmp, if equal do another cmp" as either a
comparison on tuples, or `Ordering::then_with`, depending on whether the
compare keys need construction.

`sort_by` -> `sort_by_key` when symmetrical. Do the same for
`min_by`/`max_by`.

Note that `total_cmp` can only work with `sort_by`, and not on tuples.

When sorting collected query results that contain
`Entity`/`MainEntity`/`RenderEntity` in their `QueryData`, with that
`Entity` in the sort key:
stable -> unstable sort (all queried entities are unique)

If key construction is not simple, switch to `sort_by_cached_key` when
possible.

Sorts that are only performed to discover the maximal element are
replaced by `max_by_key`.

Dedicated comparison functions and structs are removed where simple.

Derive `PartialOrd`/`Ord` when useful.

Misc. closure style inconsistencies.

## Testing
- Existing tests.
2024-12-30 22:59:36 +00:00
..
build-templated-pages Simplify sort/max_by calls (#17048) 2024-12-30 22:59:36 +00:00
build-wasm-example Fix common capitalization errors in documentation (#14562) 2024-07-31 21:16:05 +00:00
ci Add no_std support to bevy_transform (#17030) 2024-12-30 21:01:13 +00:00
compile_fail_utils Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
example-showcase Prefer Display over Debug (#16112) 2024-12-27 00:40:06 +00:00
publish.sh Remove bevy_core (#16897) 2024-12-19 18:36:51 +00:00