Target selectors are used to select certain entities. They accept different arguments to choose which entity to select. Usually, this returns a list of found entities.
limit=n parameter limits the length of the list to
n (useful with
n to get a single entity selection). The
sort parameter lets you choose which order the list of targets are sorted in.
sort parameter has 4 options,
random. The Minecraft Wiki displays what each of these do:
sort=nearest— Sort by increasing distance. (Default for @p, @e,[BE] @a[BE])
sort=furthest— Sort by decreasing distance.
sort=random— Sort randomly. (Default for @r)
sort=arbitrary— Do not sort. (Default for @e,[JE] @a[JE])
random are easy to understand in what they do. The one I am curious about is when the
arbitrary choice is selected.
The item returned by a target selector is always an ordered list. What order are they in if they are not sorted?
Here are some possible theories:
- The list is sorted by UUID.
- The list is sorted by time of creation. (newest->oldest, or oldest->newest)
- The list is sorted by position of entity. Entities are ordered in a scanline fashion, so lowest Z is first, with X from lowest to highest, followed by those on the next lowest Z.