WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

Ordinal [{cat1,cat2,,catn}]

represents the ordered set of categories cati.

Ordinal [{cat1,cat2,,catn},ci]

represents the category ci of the given categories.

Ordinal [scale]

represents a set of categories with metainformation given by scale.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Applications  
Properties & Relations  
See Also
History
Cite this Page

Ordinal [{cat1,cat2,,catn}]

represents the ordered set of categories cati.

Ordinal [{cat1,cat2,,catn},ci]

represents the category ci of the given categories.

Ordinal [scale]

represents a set of categories with metainformation given by scale.

Details

  • An ordinal scale represents a set of categories, with a specific order. Examples include movie ratings, product quality and pain level.
  • The categories cati can be any expression.
  • In Ordinal [scale], scale can be a list of categories, an OrdinalScale specification, an Ordinal expression or an Association of category information.
  • Ordinal [scale][c] is equivalent to Ordinal [scale,c].

Examples

open all close all

Basic Examples  (3)

Represent the ordered set a, b, c:

Wolfram Language code: Ordinal[{a, b, c}]

Represent the category a from within the set:

Wolfram Language code: Ordinal[{a, b, c}, a]

Create a list of categories from a category scale:

Wolfram Language code: scale = Ordinal[{"good", "better", "best"}]
Wolfram Language code: scale /@ {"best", "good", "good", "better", "best"}

Use categories with explicit scores and labels:

Wolfram Language code: scale = Ordinal[<| "CategoryList" -> {"NS", "S3", "S2", "S1"}, "LabelList" -> {"Not Suitable", "Marginally Suitable", "Moderately Suitable", "Highly Suitable"}, "ScoreList" -> {0, .5, .75, 1} |>]
Wolfram Language code: scale /@ {"S3", "NS", "NS", "S1"}

Scope  (15)

An OrdinalScale expression may be used as a scale specification:

Wolfram Language code: Ordinal[OrdinalScale[{"a", "b", "c"}], "b"]

An Ordinal expression may be used as a scale specification:

Wolfram Language code: scale = Ordinal[{"poor", "fair", "good"}]
Wolfram Language code: Ordinal[scale, "good"]

Ordinal objects use their "Score" value for sorting and ordering:

Wolfram Language code: scale = Ordinal[{"B", "C", "A"}];
Wolfram Language code: obj = scale /@ {"A", "B", "C"}
Wolfram Language code: Sort[obj]
Wolfram Language code: NumericalOrder@@Take[obj, 2]

The "Score" value will also be used in comparisons:

Wolfram Language code: obj = {Ordinal[{a, b}, a], Ordinal[{a, b}, b]}
Wolfram Language code: CategoricalValue[obj, "Score"]
Wolfram Language code: Less@@%
Wolfram Language code: Less@@obj

Ordinal objects are sorted according to their "Score" value:

Wolfram Language code: list = {Ordinal[{b, x, f}, x], Ordinal[{b, x, f}, b]};
Wolfram Language code: Sort[list]
Wolfram Language code: CategoricalValue[list, "Score"]

Ordinal objects are sorted according to their "Score" value:

Wolfram Language code: ReverseSort[RandomChoice[Ordinal[{"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}], 10]]

Ordering is determined by the "Score" values for OrdinalObject expressions:

Wolfram Language code: OrderedQ[Echo@RandomChoice[Ordinal[{"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}], 5]]

Ordering is determined by the "Score" values for OrdinalObject expressions:

Wolfram Language code: Ordering[Echo@RandomChoice[Ordinal[{"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}], 5]]

Ordering is determined by the "Score" values for OrdinalObject expressions:

Wolfram Language code: Order[Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 4], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 6]]

Ordering is determined by the "Score" values for OrdinalObject expressions:

Wolfram Language code: LexicographicOrder[Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 4], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 6]]

Ordinal objects are sorted according to their "Score" value:

Wolfram Language code: LexicographicSort[{Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 4], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 6], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 3], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 2], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 1], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 5], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 7]}]

Ordering is determined by the "Score" values for OrdinalObject expressions:

Wolfram Language code: NumericalOrder[Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 4], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 6]]

Ordinal objects are sorted according to their "Score" value:

Wolfram Language code: NumericalSort[{Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 4], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 6], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 3], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 2], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 1], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 5], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 7]}]

Information will provide detailed information about a given Ordinal expression:

Wolfram Language code: Information[Ordinal[{"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}]]

TabularColumn will automatically detect Ordinal expressions:

Wolfram Language code: ord = {Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 4], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 6], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 3], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 2], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 1], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 5], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 7]};
Wolfram Language code: TabularColumn[ord]

Normal will restore the original Ordinal expressions:

Wolfram Language code: Normal@%
Wolfram Language code: % == ord

Applications  (2)

Visualize a collection of categories with CategoricalHistogram :

Wolfram Language code: CategoricalHistogram[{Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 2], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 2], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 3], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 3], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 2], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 2], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 1], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 3], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 2], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 1], Ordinal[Association["CategoryList" -> {"first", "middle", "last"}, "LabelList" -> {"first", "middle", "last"}, "ScoreList" -> {1, 2, 3}], 2]}]

Visualize a random variate of a given category within a CategoricalDistribution :

Wolfram Language code: dist = CategoricalDistribution[Ordinal[{"Flat", "Gentle", "Moderate", "Steep", "VerySteep"}], {8, 3, 5, 2, 1}]
Wolfram Language code: RandomVariate[dist, 20]
Wolfram Language code: CategoricalHistogram[%]

Properties & Relations  (3)

Nominal expressions operate similarly to Ordinal ones, with the exception of sorting:

Wolfram Language code: cats = {"b", "c", "a"};
Wolfram Language code: nom = Nominal[cats]
Wolfram Language code: ord = Ordinal[cats]

Since there is no inherent order to Nominal categories, they follow canonical order(e.g. alphabetical):

Wolfram Language code: Sort[nom /@ cats]

As such, there is no minimum category:

Wolfram Language code: Min[nom /@ cats]

Ordinal categories are sorted by their ordering within the scale:

Wolfram Language code: Sort[ord /@ cats]

This also applies to comparisons as well:

Wolfram Language code: Min[ord /@ cats]

CategoricalValue can be used to extract the underlying expression for a category:

Wolfram Language code: CategoricalValue[Ordinal[Association["CategoryList" -> {"b", "c", "a"}, "LabelList" -> {"b", "c", "a"}, "ScoreList" -> {1, 2, 3}], 1]]

The same is true for an entire scale:

Wolfram Language code: CategoricalValue[Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}]]]

TabularColumn will automatically detect Ordinal expressions:

Wolfram Language code: ord = {Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 4], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 6], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 3], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 2], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 1], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 5], Ordinal[Association["CategoryList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "LabelList" -> {"None", "VeryLight", "Light", "Moderate", "High", "VeryHard", "Maximum"}, "ScoreList" -> {1, 2, 3, 4, 5, 6, 7}], 7]};
Wolfram Language code: TabularColumn[ord]

The "ElementType" for columns of Ordinal objects is "Ordinal":

Wolfram Language code: %["ElementType"]
Wolfram Research (2026), Ordinal, Wolfram Language function, https://reference.wolfram.com/language/ref/Ordinal.html.

Text

Wolfram Research (2026), Ordinal, Wolfram Language function, https://reference.wolfram.com/language/ref/Ordinal.html.

CMS

Wolfram Language. 2026. "Ordinal." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Ordinal.html.

APA

Wolfram Language. (2026). Ordinal. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Ordinal.html

BibTeX

@misc{reference.wolfram_2026_ordinal, author="Wolfram Research", title="{Ordinal}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/Ordinal.html}", note=[Accessed: 20-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_ordinal, organization={Wolfram Research}, title={Ordinal}, year={2026}, url={https://reference.wolfram.com/language/ref/Ordinal.html}, note=[Accessed: 20-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /