SortedEntityClass[class,prop]
represents an entity class derived from class by sorting according to the values of the property prop.
SortedEntityClass[class,prop"order"]
sorts according to prop in the order specified.
SortedEntityClass[class,{prop1,prop2,…}]
breaks ties by successively using the values of the property specifications propi.
SortedEntityClass[class,sortspec,n]
represents the first n entities of class when sorted by sortspec.
SortedEntityClass[class,sortspec,{m,n}]
represents the entities m through n of class when sorted by sortspec.
SortedEntityClass
SortedEntityClass[class,prop]
represents an entity class derived from class by sorting according to the values of the property prop.
SortedEntityClass[class,prop"order"]
sorts according to prop in the order specified.
SortedEntityClass[class,{prop1,prop2,…}]
breaks ties by successively using the values of the property specifications propi.
SortedEntityClass[class,sortspec,n]
represents the first n entities of class when sorted by sortspec.
SortedEntityClass[class,sortspec,{m,n}]
represents the entities m through n of class when sorted by sortspec.
Details
- In SortedEntityClass[class,sortspec,n], when class contains fewer than n entities, all entities are used.
- In SortedEntityClass[class,{prop1,prop2,…}], propi can be given as EntityProperty, EntityFunction or string.
- SortedEntityClass[class,prop,-n] is effectively equivalent to SortedEntityClass[class,prop->"Descending",n].
Examples
open all close allBasic Examples (5)
Use SortedEntityClass to sort a class of entities:
EntityList[SortedEntityClass["Country", "Population"]]//ShortChange the direction of the order:
EntityList[SortedEntityClass["Country", "Population" -> "Descending"]]Take only the first 10 entities:
EntityList[SortedEntityClass["Country", "Population" -> "Descending", 10]]EntityList[SortedEntityClass["Element", {"Group", "Period"}]]When used with relational-database-backed entities, SortedEntityClass is equivalent to an ORDER BY statement:
EntityRegister[EntityStore[RelationalDatabase[FindFile["ExampleData/ecommerce-database.sqlite"]]]]SortedEntityClass["payments", "amount", 10]["amount"]Scope (2)
The second argument of SortedEntityClass can be an EntityFunction:
EntityList[SortedEntityClass[EntityClass["Country", "Europe"], EntityFunction[c, c[EntityProperty["Country", "LivestockPopulation", {"FAOLivestockType" -> "Sheep"}]] / c[EntityProperty["Country", "Population"]] -> "Descending"], 3]]Get elements 10 to 15 of all rivers sorted by length in descending order:
EntityList[SortedEntityClass["River", "Length" -> "Descending", {10, 15}]]Properties & Relations (1)
When SampledEntityClass is applied to SortedEntityClass:
EntityList[SampledEntityClass[SortedEntityClass["Dinosaur", EntityProperty["Dinosaur", "Length"] -> "Descending"], 2]]The same class can be more simply expressed by using SortedEntityClass with three arguments:
EntityList[SortedEntityClass["Dinosaur", EntityProperty["Dinosaur", "Length"] -> "Descending", 2]]Tech Notes
History
Text
Wolfram Research (2019), SortedEntityClass, Wolfram Language function, https://reference.wolfram.com/language/ref/SortedEntityClass.html.
CMS
Wolfram Language. 2019. "SortedEntityClass." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SortedEntityClass.html.
APA
Wolfram Language. (2019). SortedEntityClass. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SortedEntityClass.html
BibTeX
@misc{reference.wolfram_2026_sortedentityclass, author="Wolfram Research", title="{SortedEntityClass}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/SortedEntityClass.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sortedentityclass, organization={Wolfram Research}, title={SortedEntityClass}, year={2019}, url={https://reference.wolfram.com/language/ref/SortedEntityClass.html}, note=[Accessed: 13-June-2026]}