[Question]
  [
Your task is to write a short program that represents a large (infinite) ordinal, using a well-ordering of the set of positive integers. Your program will take two different positive integers and indicate which one is greater in your chosen well-ordering. The order type of the well-order is the represented ordinal. The challenge is to min-max your code size and the represented ordinal respectively.
# Explanation
Usually the positive integers are ordered like so:
```
1, 2, 3, 4, 5, ...
```
In this ordering, the expressions: `2 < 5`, `1 < 2`, `3 < 19`, are true, as usual. The expressions `5 < 2`, `10 < 3`, and so on, are false. However, we can order the positive integers also in the following way:
```
2, 4, 6, 8, 10, ..., 1, 3, 5, 7, ...
```
Here all the even numbers are followed by all the odd numbers. Now the expressions `2 < 1`, `6 < 8`, `1 < 5`, `100 < 51` are true, and the expressions `101 < 2` `5 < 3` and `120 < 110` are false.
This is another well-ordering:
```
2, 4, 6, 8, 10, ..., 3, 9, 15, 21, ..., 5, 25, 35, 55, ..., 7, 49, 77, ..., ..., 1
```
First we have all the even numbers, then all the remaining numbers that are divisible by 3, then ones that are divisible by 5 and so on. Finally, at the very end is 1. Notice that we have a nested "...". This is allowed. What is not allowed is a "..." that starts from the left.
```
1, 3, 5, 7, 9, ..., ..., 10, 8, 6, 4, 2
```
This is not a well-order (just a total order). A more rigorous way of stating this rule is that every nonempty subset must have a smallest element. Here the subset of even numbers doesn't have a smallest element.
Another way of looking at this, is to imagine starting from the right and walking to the left. You can jump over an arbitrary (possibly infinite) amount of numbers, but you have to always go left. If the numbers are well-ordered, your walk will always take a finite amount of steps. In this example however, you can just stay on the even side, by never jumping over the three dots, thus never reaching the beginning.
Notice that if you lay the three well-orders on top of each other like so:
```
1, 2, 3, 4, 5,  ...
2, 4, 6, 8, 10, ..., 1, 3, 5,  7,  ...
2, 4, 6, 8, 10, ..., 3, 9, 15, 21, ..., 5, 25, ..., ..., 1
```
They have different "length". The bottom one is the longest, and the top one is the shortest. The "length" is called the "order type", and it can be measured with an ordinal. Our first well-order has order type \$\omega\$, the second one \$\omega\cdot2\$ and the third one is \$\omega^2+1\$
Your program will compare two positive integers, according to a well-ordering of your choice. That way your program will represent the order type of your well-order.
For more info on ordinals, visit the Wikipedia page for [ordinals](https://en.wikipedia.org/wiki/Ordinal_number) and [ordinal arithmetic](https://en.wikipedia.org/wiki/Ordinal_arithmetic). For more ordinals, visit [Googology Wiki](https://googology.wikia.org/wiki/Ordinal). Also check out the [previous infinite ordinal question on Code Golf](https://codegolf.stackexchange.com/questions/48931/make-the-largest-infinity-that-you-can).
## More ordinal examples
\$\omega\$ `1, 3, 2, 4, 5, 7, 6, 8, ...`
\$\omega^2\$ `1, 2, 4, 8, 16, ..., 3, 5, 6, 9, 10, 12, 17, 18, ..., 7, 11, 13, 14, 19, 21, 22, ..., 15, 23, 27, ..., ...`
(popcount then value)
\$\omega^2+\omega\$ `2, 4, 8, 16, 32, ..., 3, 9, 27, 81, ..., 5, 25, 125, ..., ..., 1, 6, 10, 12, 14, ...`
\$\omega^\omega\$ `1, 2, 4, 8, 16, ..., 3, 6, 12, 24, 48, ..., 9, 18, 36, 72, ..., ..., 5, 10, 20, 40, 80, ..., 15, 30, ..., 45, ..., ..., ..., etc.`
(reverse lexiographic ordering of the [standard form](https://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic))
# Rules
You must pick a well-ordering on \$\mathbb{Z}^+\$. A well ordering is a binary relation \$<\$ such that for all distinct elements \$a\$, \$b\$, \$c\$, \$a<b\space\veebar\space b<a\$ and \$a<b\space\land\space b<c\implies a<c\$ and also for every nonempty subset \$S\$ of \$\mathbb{Z}^+\$, there is a minimal element \$m\$, so that for every other member \$n\$ in \$S\$, \$m<n\$.
Your program will receive two distinct positive integers \$a\$ and \$b\$ in some reasonable format. The program will output TRUE if \$a<b\$ and FALSE otherwise. Instead of "TRUE" and "FALSE", you can choose any two distinct output strings, such as ("true", "false"), ("1", "0") and so on.
Instead of reading from stdin/cmdline and writing to sdtout, you can make a function that takes two integers. The function should still have only two possible (distinct) return values, although they don't have to be strings.
If your programming language has no built-in bignum support, you can assume that a native integer datatype has infinite range (doesn't overflow).
# Scoring
Your score is the tuple \$(Value, Bytes)\$ where \$Value\$ is the represented ordinal and \$Bytes\$ is the number of bytes in your program. For example, if you implement the ordinal \$\omega^3+\omega\$ in 6 bytes, your score is \$(\omega^3+\omega, 6)\$.
To compare scores we define a partial order \$\ge\$ so that \$(v\_0, b\_0)\ge (v\_1, b\_1)\$ iff \$v\_0\ge v\_1\$ and \$b\_0\le b\_1\$. A score \$(v\_0, b\_0)\$ is better than a score \$(v\_1, b\_1)\$ iff \$(v\_0, b\_0)\ge (v\_1, b\_1)\$ and the scores are not equal.
In other words, your submission is better than another submission, if you achieve more bang-for-buck. That is, you achieve a bigger ordinal with the same number of bytes, or achieve the same ordinal, with a smaller amount of bytes. And obviously if you achieve a bigger ordinal with fewer bytes, your submission is better.
This does mean that some scores can't be compared. For example, \$(\omega\cdot 2, 2)\$ and \$(\omega^2, 4)\$ are incomparable.
You are a winner if there is no submission that is better than yours.
If there are two or more submissions with the exact same score, the one submitted first is the winner. Since some scores can't be compared with others, there can be multiple winners. You are free to make multiple submissions, and possibly have multiple winning ones.
# List of winning submissions
| Bytes | Value | Language and Author |
| --- | --- | --- |
| 1 | \$\omega\$ | [Polyglot - community wiki](https://codegolf.stackexchange.com/a/237343/84290) |
| 6 | \$\omega^\omega\$ | [Pyth - Anders Kaseorg](https://codegolf.stackexchange.com/a/237303/84290) |
| 12 | \$\omega^\omega+1\$ | [Husk - Dominic van Essen](https://codegolf.stackexchange.com/a/237301/84290) |
| 17 | \$\varepsilon\_0\$ | [Pyth - Anders Kaseorg](https://codegolf.stackexchange.com/a/237303/84290) |
| 208 | \$\phi\_{\Omega^\omega}(0)\cdot\omega\$ | [Haskell - Grain Ghost](https://codegolf.stackexchange.com/a/237294/) |
| 218+2\$n\$ | \$\phi\_{\Omega^\omega}(0)^n\cdot\omega\$ | [Haskell - Grain Ghost](https://codegolf.stackexchange.com/a/237294/) |
 
  
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), \$(ω^ω, 6)\$
```
>_PE_P
```
[Try it online!](https://tio.run/##K6gsyfj/3y4@wDU@4P9/QyNjLhNTMwA "Pyth – Try It Online")
Compares the reversed prime factorizations of the two inputs.
# [Pyth](https://github.com/isaacg1/pyth), \$(ε\_0, 17)\$
```
L_SmylP#U_dPb>yEy
```
[Try it online!](https://tio.run/##K6gsyfj/3yc@OLcyJ0A5ND4lIMmu0rXy/39DI2MuE1MzAA "Pyth – Try It Online")
```
L                     def y(b):
           Pb           prime factors of b
   m                    map over d:
         _d               -d
        U                 range [-d, …, -1]
      P#                  filter for (negated) primes
     l                    count
    y                     recursively call y
  S                     sort
 _                      reverse
             >yEyQ    y(second input) > y(first input)
```
The ordinal corresponding to each positive integer is given by
$$α(p\_{i\_0}p\_{i\_1} \dotsc p\_{i\_{c-1}}) = \sum\_k ω^{α(i\_k)}$$
where \$p\_i\$ is the \$i\$th prime, and the sum on the right is taken in nonincreasing order of \$α(i\_k)\$ (since ordinal addition isn’t commutative). This allows us to build any ordinal with a finitely long [Cantor normal form](https://en.wikipedia.org/wiki/Ordinal_arithmetic#Cantor_normal_form). For example:
```
α(1) = 0,          y(1) = []
α(2) = 1,          y(2) = [[]]
α(4) = 2,          y(4) = [[], []]
α(8) = 3,          y(8) = [[], [], []]
α(16) = 4,         y(16) = [[], [], [], []]
α(3) = ω,          y(3) = [[[]]]
α(6) = ω + 1,      y(6) = [[[]], []]
α(12) = ω + 2,     y(12) = [[[]], [], []]
α(9) = ω·2,        y(9) = [[[]], [[]]]
α(18) = ω·2 + 1,   y(18) = [[[]], [[]], []]
α(27) = ω·3,       y(27) = [[[]], [[]], [[]]]
α(7) = ω^2,        y(7) = [[[], []]]
α(14) = ω^2 + 1,   y(14) = [[[], []], []]
α(21) = ω^2 + ω,   y(21) = [[[], []], [[]]]
α(49) = ω^2·2,     y(49) = [[[], []], [[], []]]
α(19) = ω^3,       y(19) = [[[], [], []]]
α(5) = ω^ω,        y(5) = [[[[]]]]
α(10) = ω^ω + 1,   y(10) = [[[[]]], []]
α(15) = ω^ω + ω,   y(15) = [[[[]]], [[]]]
α(35) = ω^ω + ω^2, y(35) = [[[[]]], [[], []]]
α(25) = ω^ω·2,     y(25) = [[[[]]], [[[]]]]
α(13) = ω^(ω + 1), y(13) = [[[[]], []]]
α(23) = ω^(ω·2),   y(23) = [[[[]], [[]]]]
α(17) = ω^ω^2,     y(17) = [[[[], []]]]
α(11) = ω^ω^ω,     y(11) = [[[[[]]]]]
α(31) = ω^ω^ω^ω,   y(31) = [[[[[[]]]]]]
```
# [Pyth](https://github.com/isaacg1/pyth), \$(ε\_0, 19)\$
```
L_S.ey-bkx1_jb2>yEy
```
[Explanation](https://codegolf.stackexchange.com/revisions/237303/8) for this old answer, which is now obsolete, but may be of interest for porting to languages lacking prime-related builtins.
[Answer]
# [Haskell](https://www.haskell.org/), \$(\omega, 3)\$
This solution is dead simple, really can't be beat in Haskell.
```
(<)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P81Ww0bzf25iZp5tQVFmXolKmoKRgonpfwA "Haskell – Try It Online")
# [Haskell](https://www.haskell.org/), \$(\omega+n,19+2\left\lfloor\log\_{10}(n+1)\right\rfloor)\$
Here's a scheme to get \$\omega + n\$ for any \$n\in\mathbb{N}\$. Just replace the `9`s below with one more than \$n\$. This will make the first \$n\$ numbers bigger than all other numbers but otherwise compare normally.
```
x#y=(x<9,x)<(y<9,y)
```
[Try it online!](https://tio.run/##y0gszk7NyfmfmVuQX1Si4JJYkqjnk1lc8r9CudJWo8LGUqdC00ajEkhXav5Pzs8tUEhUSKpJtLVNsnUNrElUTrL1CeGCidu6h3DlJmbm2RYUZeaVqBQDTXSqVADLRhvq6RkaGMT@BwA "Haskell – Try It Online")
Looks like the leader board should now have an infinite number of winners. However we can beat an infinite number of these pretty easily. Most of this can just be done by fiddling with things a little bit up until we hit 26 bytes. So I will present my scores for 21, 23 and 25 without individual commentary. They should be pretty clear modifications of the 19 byte case.
### 21 bytes, \$\omega+98\$
```
x#y=(x<99,x)<(y<99,y)
```
### 23 bytes, \$\omega+387420488\$
```
x#y=(x<9^9,x)<(y<9^9,y)
```
### 25 bytes, \$\omega+9^{99}-1\$
```
(.q).(<).q
q x=(x<9^99,x)
```
Luckily this wraps up by 26 we can get to a much larger ordinal:
# [Haskell](https://www.haskell.org/), \$(\omega\cdot n,26+\left\lfloor\log\_{10}(n)\right\rfloor)\$
*Thanks to the OP for pointing out that I didn't need division for this.*
Another scheme much like the last, replace `9` with the desired number.
```
(.q).(<).q
q x=(mod x 9,x)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P81WQ69QU0/DRlOvkKtQocJWIzc/RaFCwVKnQvN/bmJmnm1BUWZeiUqagomCsel/AA "Haskell – Try It Online")
Once again we can use kolmogorov complexity to improve some of these. Here's a few that are currently records for their respective program sizes.
### 28 bytes, \$\omega\cdot 9^9\$
```
(.q).(<).q
q x=(x`mod`9^9,x)
```
### 29 bytes, \$\omega\cdot 9^{99}\$
```
(.q).(<).q
q x=(x`mod`9^99,x)
```
### 30 bytes, \$\omega\cdot 9^{9^9}\$
```
(.q).(<).q
q x=(x`mod`9^9^9,x)
```
### 31 bytes, \$\omega\cdot 9^{9^{99}}\$
```
(.q).(<).q
q x=(x`mod`9^9^99,x)
```
### 32 bytes, \$\omega\cdot 9^{9^{9^9}}\$
```
(.q).(<).q
q x=(x`mod`9^9^9^9,x)
```
### 33 bytes, \$\omega\cdot 9^{9^{9^{99}}}\$
```
(.q).(<).q
q x=(x`mod`9^9^9^9,x)
```
# [Haskell](https://www.haskell.org/), \$(\omega^\omega, 63)\$
Implements the order for \$\omega^\omega\$ in the question.
```
n#1=[]
n#a|mod a n<1=n#div a n++[n]|m<-n+1=m#a
y=(.(2#))
f=y.y(<)
```
[Try it online!](https://tio.run/##PY6xCoMwFEX3fEUgHRRpMJ19S2np4lJwE4dnVRqaPK2mhUD@PdVCu93DPXDvHZdHb0zUdhpnx58vNHrQfcdP6FCWenGRhIK6YSQw2LHjyKlQQKLT7y1nWU1NsMWeMgVWIPOQyOQg0pQN4KVPijTeRjutbhsQoIXzNQwbQVmxXwOXilnUBNOsye3@43JZXx09/3q1klLleRM/ "Haskell – Try It Online")
# [Haskell](https://www.haskell.org/), \$(\phi\_{\Omega^\omega}(0)\cdot\omega,208)\$
This implements the same ordinal as in [cardboard\_box's answer](https://codegolf.stackexchange.com/a/237306/56656). It's slightly bigger than the small Veblen ordinal \$\phi\_{\Omega^\omega}(0)\$.
This could certain be golfed more. I'm not sure that either the type or the instance are really necessary, but for now it puts Haskell back on the leaderboard.
```
data T=T[T]deriving Eq
instance Ord T where a<=b=a==b||a<b;T a<T b=any(T a<=)b||(all(<T b)a&&(l a,a)<(l b,b))
l=length
c x|odd x,(y,t)<-c$div x 2=(T t:)<$>c y|1>0=(div x 2,[])
g f x|(y,t)<-c x=f(T t,y)
g.g(<)
```
[Try it online!](https://tio.run/##hVLbitswEH3XVwxsWGxwir2l0Iu1T01LYWEp67cQythWZFFZztrKOqHpt6cj52bnQjHBztGZc86MpsDmt9B6@2d8B09o5BKlgBeLJkddGfFV1OpNGQl347/bHC1CwpNpMssP@OSVKdMQPxPwXOeQQFuIWgDGPOXIebrZYJx@SQhIgBCz9tw39@nAQ609B/t4f@9pwAD9mN5pkPo@01wLI23BMlhtqjyHVeCtA@vH42yUqzdYwQMnLfvZj0ePGaw30WPIvf1JMJ35TMKcSg9FsOJzxw/WPptz@U56sb899nFs4qWoWkgYG4/huRQSWQscqOXpLKDfrDv4YayQoobKESCNwoi1vxT/cKoCW4EtxI7B2oOGU7gl069wmmFEqk42@tSxJ4tG0ZWAwaUsLBNhP9elqBjQu5AUU4Qk@BB1zG9iLuoSDbW8FNaSdZ0rg5rJ8Czupfqt2p2Piy6d08f3jJWoDM8rBrColbEwggyoreH/c8DlHABOjhFyHLB4XaJu9gPuMatygbR/LT2cw@TnoEg1oEXT0KAp@uXYr@t0Qk9J73DuGtiF7qsPbpCsZC3Q0rBObtcM9km/J7eTDu/yakq3DldTitPghht0PeH/5kE@7SHvwOrM67Qg2dmGqKYz0FhL0fSbKXGlymUJ0zZo20CEgQxnzkmGF03J4Xrs7S9Ql6dDt/8A "Haskell – Try It Online")
# [Haskell](https://www.haskell.org/), \$(\phi\_{\Omega^\omega}(0)^n\cdot\omega,218+2n)\$
This example code at 222 bytes, iterates the previous algorithm twice. Giving \$\phi\_{\Omega^\omega}(0)^2\cdot\omega\$.
```
data T=T[T]deriving Eq
instance Ord T where a<=b=a==b||a<b;T a<T b=any(T a<=)b||(all(<T b)a&&(l a,a)<(l b,b))
l=length
c x|odd x,(y,t)<-c$div x 2=(T t:)<$>c y|1>0=(div x 2,[])
g f x|(y,t)<-c x=(T t,f y)
r=g$g id
f=(.r).(<).r
```
[Try it online!](https://tio.run/##hVPvi9pAEP2@f8XAyZG0URKPQq9171NtKRwc5fJNpKxmXJcmG2@zGqXe325nE3/GSAkSeTvz3pvZl7ko/mCa7v527@BZaLkUEuHVCp2INNf4DY1aKS3hrvu@S4QVEPN4FI@TAz58Y0oXVD9FeDEJxFDO0SCIAZ9wwflkuxWDydeYgBgI0RvP/ec@HXgiTT0H@@L@3ktBBMIf0HsSTHyfpTxFLe2cTWG9zZME1oG3Caw/6E47iVrBGvqcuOwXf9B5msJmGz2F3NufBKOxzyTMqPXQBOuqPJjBxmeGy44ElbAZ93rG73kDv2d2x6mOI73O8xJixrpdeMlQClYCB1rAaBzQb1wd/NQWJRrIXQFMojBi5W/FP526wOZg51hXsPLA4Rhu0Zx3OM4wIlZHGz1W1cNFoeiCQIulnFuG4bmva1K8KK9Mkk0MibAfVZXfcYYmE5pGXqK1JG0SpUXKZNiwe81@q7fWcdalU/r8UK9kf1gqCwUNCCnObL5CUzCDmQsRh@jxw0P/I60wE0rzJGcAC6O0hQ64awPaxBXUgrkBm5hswWrdM9Q0FEyT3jS5TZPYHFgJOwYB35YiLfZBONVO82wh6Ksp6eEchr8umlRBKyoKCgSt@Doe7TwV0XN8djhzM9VznLNfJI2kpEFh6VJPam0Ce6c/4ttOLzPX6tLFttVltdya@TLp7Q7/tw/SKQ9@L6QaWqcgTxtJVkUlkAojsTgfJhNrlS0zGJVBWQYYBjIcOyUZXg3VCMhe/gp1fip09w8 "Haskell – Try It Online")
Every time we add a `g$` to the front of the definition of `r` we add 1 to the power at the cost of two bytes.
---
## Haskell Leaderboard
~~Since Haskell has been complete removed from the main leaderboard,~~ for now I am maintaining a short list of Haskell winners here
| Bytes | Value | Author |
| --- | --- | --- |
| 3 | \$\omega\$ | Grain Ghost |
| 19 | \$\omega+8\$ | Grain Ghost |
| 21 | \$\omega+98\$ | Grain Ghost |
| 22 | \$\omega\cdot 2\$ | [xnor](https://codegolf.stackexchange.com/a/237304/56656) |
| 24 | \$\omega\cdot 4\$ | [xnor](https://codegolf.stackexchange.com/a/237304/56656) |
| 25 | \$\omega\cdot 12\$ | [xnor](https://codegolf.stackexchange.com/a/237304/56656) |
| 26 | \$\omega\cdot 32\$ | [xnor](https://codegolf.stackexchange.com/a/237304/56656) |
| 27 | \$\omega\cdot 99\$ | Grain Ghost |
| 28 | \$\omega\cdot 9^9\$ | Grain Ghost |
| 29 | \$\omega\cdot 9^{99}\$ | Grain Ghost |
| 30 | \$\omega\cdot 9^{9^9}\$ | Grain Ghost |
| 31 | \$\omega\cdot 9^{9^{99}}\$ | Grain Ghost |
| 32 | \$\omega\cdot 9^{9^{9^9}}\$ | Grain Ghost |
| 33 | \$\omega\cdot 9^{9^{9^{99}}}\$ | Grain Ghost |
| 34 | \$\omega^{10}\$ | [xnor](https://codegolf.stackexchange.com/a/237304/56656) |
| 53 | \$\omega^\omega\$ | [AnttiP](https://codegolf.stackexchange.com/a/237342/84290) |
| 208 | \$\phi\_{\Omega^\omega}(0)\cdot\omega\$ | Grain Ghost |
| 218+2\$n\$ | \$\phi\_{\Omega^\omega}(0)^n\cdot\omega\$ | Grain Ghost |
 
[Answer]
# [Python 2](https://docs.python.org/2/), \$\psi\_0(\Omega^{\Omega^\omega})\cdot\omega\$ with respect to Buchholz's psi, 266 bytes
```
l=len
T=lambda i,s='(',d=1:T(i/2,s+['),','('][i%2],d+i*2%4-1)if d else(eval(s)[0],i)
L=lambda A,B:any(A==b or L(A,b)for b in B)or all(L(a,B)for a in A)and(l(A)-l(B),0)<(0,next((L(a,b)for a,b in zip(A,B)if a!=b),0))
def f(a,b):A,a=T(a);B,b=T(b);return(a,0)<(b,L(A,B))
```
[Try it online!](https://tio.run/##hVTLbtswEDxbX7GBUZismVaSe0orFDZQ9OKj0R4MJ6AsOmEqUwKp1HF/Pl0@9HJSND5EmhkOl7vi1OfmoVLpy0uZlUJFm6zkx7zgIJnJZmTGiiy52RD5MWVmvp1RNmOI7rbyXbpjxVy@T999uk6oPEABojSCiN@8JIZu4x2TNFq3dku2uuHqTJZZlkOlYU2WLKcHfMpBKlhRfOJlSdaEs5XDucWXlKuClGRJr0uyoiymX0jMlHhuiJN6C/xvxX9kja4rWwy/ynKrplEhDnBwypsl49mGcPp5xXJ8yOlnLZonrZC1vjlbu@X0ZQobYRpoHngDG6h1VQtdnqHRXJmSN8KAejrmQhtoKkQFAnPQ4silKoSONnd7bhDLYBtNtnEeMyCUAXbEvSbhPQnvcZwggMhIMwAHwhYdq2NkHOHgS6JbY9nRHvb3psJzqNtFkW2wZPaUrDui7XY45U00wX7jF0LhKgMy1lFkJ5pLI@Db817UjawUmf3Ulbp3fbua0SgadnsNp0r/MsANiOda7BtRQKXAVEfhG/0hwvY3d77prsG2lZd/U4iR8E26IBJLtH0aEqkjAtNzU1h4K0LHZlM4AZFHfi@VcMXPsGwFWOk9p2ETu2awyi6Zhwo6tuU9mYbNwiQG5Z1aT0/1y9LO1JL@AD27OPWOuGHnidvdpgNLx3nWUReertYx3RfU86jo6JFDf9yBJB3WFmqwe1h@0c2JjBtxuj31kyKjTiDV9ddzZHzgV2vJ4EwjuiVJV9BA4O7fRVmiNrKsVNxtflFbyw8KvLCZwnd@PPJ4sMOIrXQhFS@hOuDnhp@c0IrrM/wQOQY3PEihud4/nIHXNddCNeX5q72//gLbG4vxdS8Iikl/h6i9olbx2CvkHPPgDdmE443rsa3cIZaPsUfccWITYY15yqmNelXhvfYJjNTrOFjxwt1t2FdHrFyaSrlcwGBYlqZy7oAhjlYuB0L2hiSQqglBMMEedcnDvGXoWTRxKRyigdl0CLkbgCQAFnLAyQJJHD6OJCxJvMQBQRF7j7RXeI80mCZJUCxaRRIUi1YRO5MpfLKK3b8HZo/6/3l1qn5cFrqYloMed35Wh9GsDv@ZFS59NapaI0pmNsgN1NwYUXywxMtf "Python 2 – Try It Online")
At least I think that's how this ordinal is written. It's a little bigger than the [Small Veblen ordinal](https://en.wikipedia.org/wiki/Small_Veblen_ordinal).
`T` is a bijective function that maps natural numbers `n` to tuples `(tree,remainder)` of ordered trees and natural numbers. It does so by treating the reversed binary representation of the input as a sequence of `(`s and `)`s, prepended by an extra `(`. Once the initial `(` is given a matching `)`, the unused bits form the remainder. For example, `37` is `100101` in binary, which gets reversed to `101001` which becomes `( ()()) 1`, giving `(()())` as the tree and `1` as the remainder.
`L` is a well ordering of ordered trees, the ordinal of which is the small Veblen ordinal. It is taken from Jervell, Herman Ruge (2005), "Finite Trees as Ordinals" (which I found via the Wikipedia article linked above). I horizontally mirrored it because it made the code shorter.
`f` accepts 2 natural numbers, converts them to `(tree,remainder)` tuples, and compares these by remainder first, then by tree.
Numbers which map to tuples in the form `(tree, 0)` form the small Veblen ordinal.
Tuples in the form `(tree, 1)` come next, then `(tree, 2)`, `(tree, 3)` etc. for a total of \$\omega\$ copies of the small Veblen ordinal, which I think is written \$\phi\_{\Omega^\omega}(0)\cdot\omega\$.
Note: while I defined `f` in terms of non-negative integers, the ordinal doesn't change if you only use strictly positive integers.
[Answer]
# Polyglot, \$(\omega, 1)\$
Feel free to add languages to the list.
```
<
```
Try it in:
* [Actually](https://tio.run/##S0wuKU3Myan8/9/m/39DUxNzE2NTQyNTAzMzQ0NLLgsjM0tLA2Mzc1NjQ0MLQyMA "Actually – Try It Online"). Outputs `0`/`1`.
* APL family languages: [APL](https://tio.run/##SyzI0U2pTMzJT///P@1R2wSb//8NTU3MTYxNDY1MDczMDA0tFdIULIzMLC0NjM3MTY0NDS0MjQA), [J](https://tio.run/##BcHJEQAgCASwViiB5cbRdnzY/x@TN3PP2jNwS1OHOEcATZdKops10hUoyAc), [K](https://ngn.bitbucket.io/k/#eJwFwckRACAIBLA/1bDcqJ04fum/BJNZh2gu3NLUIc4RQO+S6GaNdAUK8j66FgjN), [BQN](https://mlochbaum.github.io/BQN/try.html#code=RuKGkDwKMTU0NzQzNTEyNTA2NjExOSBGIDgyNjk5MDM2NzUzMTE4MTI=). Outputs `1`/`0`.
* [Jelly](https://tio.run/##BcHJDQAgDAOwlZrelViHD2IBpg/22fc@cpFEeLkFNCQTGLbmjFhWGNDQDw "Jelly – Try It Online"). Outputs `1`/`0`.
* [Keg](https://tio.run/##y05N///f5v9/Q1MTcxNjU0MjUwMzM0NDSy4LIzNLSwNjM3NTY0NDC0MjAA "Keg – Try It Online"). Outputs `0`/`1`.
* [MathGolf](https://tio.run/##y00syUjPz0n7/9/m/39DUxNzE2NTQyNTAzMzQ0NLBQsjM0tLA2Mzc1NjQ0MLQyMA "MathGolf – Try It Online"). Outputs `0`/`1`.
* [MATL](https://tio.run/##BcGxEQAgCASw3ml4kAfuXMZeO/fH5O53ulc3fMY0h7qQQI1UVokx3ICEfg "MATL – Try It Online"). Outputs `1`/`0`.
* [Pyt](https://tio.run##BcG5EQAgCATA3Go44HhmLMrAxOpx97w7s2dATzdCKRFAr9LoFoukAQX9 "Pyt – Try It Online"). Outputs `False`/`True`.
* [Stax](https://tio.run/##Ky5JrPj/3@b/f0NTE3MTY1NDI1MDMzNDQ0sFCyMzS0sDYzNzU2NDQwtDIwA "Stax – Try It Online"). Outputs `1`/`0`.
* [Vyxal](https://lyxal.pythonanywhere.com?flags=&code=%3C&inputs=1547435125066119%0A8269903675311812&header=&footer=). Outputs `0`/`1`.
Also one byte in [05AB1E](https://tio.run/##yy9OTMpM/f//UcPO//8NTU3MTYxNDY1MDczMDA0tuSyMzCwtDYzNzE2NDQ0tDI0A "05AB1E – Try It Online"), but `‹` instead of `<`. Outputs `0`/`1`.
[Answer]
# [Python 3](https://docs.python.org/3/), \$(\omega^2,28)\$
```
lambda a,b:(a&-a,a)<(b&-b,b)
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSFRJ8lKI1FNN1EnUdNGI0lNN0knSfN/QVFmXolGmoZBkqGhgYEOkDIA0pqaXCgShmAJsPh/AA "Python 3 – Try It Online")
[Old version](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSFRJ8lKIzEuUa1ON1EnUdNGIykuCchO0knS/F9QlJlXopGmYZBkaGhgoAOkDIC0piYXioQhWAIs/h8A "Python 3 – Try It Online")
This orders by number of trailing zeros (of binary rep) first and then by the number itself.
[Answer]
## [Haskell](https://www.haskell.org/), \$ \omega \cdot 2\$, 22 bytes
```
(.q).(<).q
q=odd>>=(,)
```
[Try it online!](https://tio.run/##y0gszk7NyfmfmVuQX1Si4JJYkqjnk1lcwpVmG/NfQ69QU0/DRlOvkKvQNj8lxc7OVkNH839yfm6BQqJCUk2irW2SrWtgTRqIZ@sTwgWTsXUP4cpNzMyzLSjKzCtRKQYa7VSpAJaNNtTTs7S0jP3/LzktJzG9@L9uckEBAA "Haskell – Try It Online")
Based off [Grain Ghost's Haskell answers](https://codegolf.stackexchange.com/a/237294/20260_). The function `q` is pointfree for `q x=(odd x,x)`. That is, we sort numbers by whether they're odd, then the number itself, which gives the evens followed by the odds. We can generalize this idea as:
### [Haskell](https://www.haskell.org/), \$ \omega \cdot 4\$, 24 bytes
```
(.q).(<).q
q=gcd 6>>=(,)
```
[Try it online!](https://tio.run/##y0gszk7NyfmfmVuQX1Si4JJYkqjnk1lcwpVmG/NfQ69QU0/DRlOvkKvQNj05RcHMzs5WQ0fzf3J@boFCokJSTaKtbZKta2BNGohn6xPCBZOxdQ/hyk3MzLMtKMrMK1EpBhruVKkAlo021NOztLSM/f8vOS0nMb34v25yQQEA "Haskell – Try It Online")
Partitions numbers by the greatest common divisors with 6, which is one of `[1,2,3,6]`. In general, we can replace 6 with any number \$c\$, and get order type \$ \omega \cdot \sigma(c)\$, where \$ \sigma(c)\$ counts the divisors of \$c\$. For instance:
### [Haskell](https://www.haskell.org/), \$ \omega \cdot 12\$, 25 bytes
```
(.q).(<).q
q=gcd 60>>=(,)
```
[Try it online!](https://tio.run/##y0gszk7NyfmfmVuQX1Si4JJYkqjnk1lcwpVmG/NfQ69QU0/DRlOvkKvQNj05RcHMwM7OVkNH839yfm6BQqJCUk2irW2SrWtgTRqIZ@sTwgWTsXUP4cpNzMyzLSjKzCtRKQaa7lSpAJaNNtTTs7S0jP3/LzktJzG9@L9uckEBAA "Haskell – Try It Online")
For 3 digits, 840 gives \$ \omega \cdot 32\$ for 26 bytes. The optimal values of \$c\$ to use are [Highly Composite Numbers](https://en.wikipedia.org/wiki/Highly_composite_number).
---
## [Haskell](https://www.haskell.org/), \$\omega^{10}\$, 34 bytes
```
(.q).(<).q
q=scanl1 min.show>>=(,)
```
[Try it online!](https://tio.run/##Nc27CsIwFIDhPU@RwaEBPdAx4OkgiksXoZs6nAZjQ3NrExChz268gOPPN/wDpfFmbTEuhjnzPWWC1qTMNF5KBZOAaitgYhMmRd7W3BkPaQiPpsFqLYoKLnLi/UKIPR5Oi/4Wth37Cx475sh4jLPxeZU@m92T//RcA0gpr@WltKV7KhsV4xs "Haskell – Try It Online")
The helper `scanl1 min.show` takes the decimal representation of a number and computes the running minimum, resulting in a non-increasing sequence. For example, `45271` becomes `44521`. We then compare these representations lexicographically, tiebroken by the number itself.
Let's show that the non-decreasing finite lists of digits \$0,\dots,9\$ are in well-ordered, with order type \$\omega^{10}\$. The lexicographic comparison first checks which sequence has more 9's in the prefix, tiebroken by whichever is followed by more 8's, and so on down to which ends with more 0's. So, if we represent the list as \$a\_9\$ 9's followed by \$a\_8\$ 8's, and so on to \$a\_0\$ 0's, the comparison is equivalent to comparing \$a\_9, a\_8, \dots, a\_0\$ lexicographically. Each \$a\_i\$ is an arbitrary natural number, so this is exactly the order type \$\omega^{10}\$.
The `scanl min` operation suffices to obtain almost every non-increasing sequence of digits 0 through 9, as is seen by it leaving the numbers represented by these digits unchanged -- the only exception is sequences made of only 0's, but their omission doesn't affect the order type. Moreover, each such sequence is produced by a finite number of values, a subset of the numbers with that many digits, and it doesn't matter what the tiebreak is among these values as long as there are no ties. So, the order type produced by the main function is also \$\omega^{10}\$.
Sorting the digits in decreasing order would have also worked, but Haskell doesn't have a built-in sort. In other languages, sorting would likely be the way to go.
If we could remove the cap of 9 from the values of the digits, we'd get order type \$\omega^{\omega}\$
[Answer]
# [Husk](https://github.com/barbuz/Husk), \$\omega\$, 2 bytes
```
¬<
```
[Try it online!](https://tio.run/##yygtzv6f6/aoqfH/oTU2////j4421DGO1Yk2ApPGYNIETJqCSTMwaQ4mLcCkJZg0NABSsQA "Husk – Try It Online")
Boring single-omega solution: well-ordering is just normal integer order (example 1 in question).
---
# [Husk](https://github.com/barbuz/Husk), \$\omega\$+1, 7 bytes
```
¬F<σ7\0
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8f@hNW4255vNYwz@//8fHW2oYxSrE22kYwgkDXXMgaQ5mG0BZVvExgIA "Husk – Try It Online")
Omega+1: well-ordering is integers starting at 1 in normal order, but missing 7, and finally with 7 last, so: 1,2,3,4,5,6,8,9,10,...,7.  
Change the `7` in the code to select any other digit at the end.
---
# [Husk](https://github.com/barbuz/Husk), \$\omega\$.2, 11 bytes
```
¬F<m?o_\I%2
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8f@hNW42ufb58TGeqkb///@PjjbWMYzVAZJGYNIETJoCSROwuAlY3AQqYhYbCwA "Husk – Try It Online")
Odd numbers first, then even numbers, so: 1,3,5,7,...,2,4,6,8,... .
---
# [Husk](https://github.com/barbuz/Husk), \$ω^ω\$, 6 bytes
```
¬¤<(↔p
```
[Try it online!](https://tio.run/##yygtzv7//9CaQ0tsNB61TSn4//@/8X8zAA "Husk – Try It Online")
Port of [Neil's omega^omega approach](https://codegolf.stackexchange.com/a/237296/95126): gets the reversed (`↔`) `p`rime factors of each `¤` argument, and compares them lexicographically (`<`), finally taking the logical NOT (`¬`) to ensure only two output values.
---
# [Husk](https://github.com/barbuz/Husk), \$ω^ω\$+1, 12 bytes
```
¬¤>?o↔pȯ;\←←
```
[Try it online!](https://tio.run/##yygtzv7//9CaQ0vs7PMftU0pOLHeOuZR2wQg@v//v5HJf0MjAA "Husk – Try It Online")
Lexicographic ordering of reversed prime factors of inputs minus 1, but finally with `1` last: subtract 1 (`←`) from each (`¤`) input, then if the result is falsey (zero), convert it to a list containing infinity (`ȯ;\←`), otherwise make a list of its reversed (`↔`) `p`rime factors, before comparing them (`>`) and taking the logical NOT (`¬`).
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), \$ω^2\$, 10 bytes
```
‹⟦ΣθＮ⟧⟦ΣηＮ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMMntbhYIzq4NFejUFNHwTOvoLTErzQ3KbVIQzNWRwEskYEhoalp/f@/oYEll6Xlf92yHAA "Charcoal – Try It Online") Link is to verbose version of code. Orders by sum of digits, then regular ascending order, resulting in the following ordering:
`1, 10, 100, ..., 2, 11, 20, 101, 200, ..., 3, 12, 21, 30, 102, 111, 120, 201, 210, 300, ..., 4, 13, 22, 31, 40, 103, 112, 121, 130, 202, 211, 220, 301, 400 ..., ...`
# [Charcoal](https://github.com/somebody1234/Charcoal), \$ω^2\cdot 9\$, 14 bytes
```
‹⟦⌈θΣθＮ⟧⟦⌈ηΣηＮ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMMntbhYI9o3sSIztzRXo1BTRyEYSnvmFZSW@JXmJqUWaWjG6ijAFWVAFWVgKNLUtP7/39DAksvS8r9uWQ4A "Charcoal – Try It Online") Link is to verbose version of code. Orders by greatest digit, then sum of digits, then regular ascending order, resulting in the following ordering:
`1, 10, 100, ..., 11, 101, ..., 111, ..., ... 2, 20, 200, ..., 12, 21, 102, 120, 201, 210, ..., 22, 112, 121, 202, 211, 220, ..., ... 9, 90, 900, ..., 91, 109, 190, 901, 910, ..., 92, 119, 191, 209, 290, 902, 911, 920, ..., ...`
# [Charcoal](https://github.com/somebody1234/Charcoal), \$ω^3\$, 16 bytes
```
‹⟦ΣΣθΣθＮ⟧⟦ΣΣηΣηＮ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMMntbhYIzq4NFcDhAs1NXUUIAwdBc@8gtISv9LcpNQiDc1YHQW4qgyYqgwMVZqa1v//GxpYclla/tctywEA "Charcoal – Try It Online") Link is to verbose version of code. Orders by sum of digits of sum of digits, then sum of digits, then regular ascending order, resulting in the following ordering:
`1, 10, ..., 19, 28, 37, 46, 55, 64, 73, 82, 91, ..., ... 2, 11, 20, ..., 29, 38, 47, 56, 65, 74, 83, 92, ..., ... 3, 12, 21, 30, ..., 39, 48, 57, 66, 75, 84, 93, ..., ... 4, 13, 22, 31, 40, ..., 49, 58, 67, 76, 85, 94, ..., ...`
# [Charcoal](https://github.com/somebody1234/Charcoal), \$ω^ω\cdot 9\$, 29 bytes
```
Ｆ²⊞υ⟦Ｎ⟧Ｗ›⌈Ｅυ⌊κ⁹Ｆυ⊞κΣ⌊κ›⮌⊟υ⮌⊟υ
```
[Try it online!](https://tio.run/##XYy9CsIwFIX3PMUdcyEOuoU@gDhUQh3FIZZIQvNT0qT69jEpIuJ0OIfvfKOWcQzSlvIIEegBQeRF08zgevJzTufs7ipSvGFHntpYBfQYlUx16@XLuOxqzo3vjd/qhIgMOCJsxvwxTgwuDf6hOiKi8ekrHNSq4qKoCFXYJH9DfZSy55xwXnarfQM "Charcoal – Try It Online") Link is to verbose version of code. Repeatedly sums the digits of the inputs until they both reach their digital root, then compares the results in reverse order from the digital root working back to the original input. Since there are 9 digital roots and a potentially arbitrary number of summation steps I think I have the correct value for this. For small inputs the ordering is the same as the previous version; it first diverges for 199, which for instance compares less than 99 here but not in the previous ordering.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), \$ω^ω\$, 54 bytes
```
\d+
$*
+`\b(11+)(\1)+\b
$1 1$#2$*
^(.+)(,\1|\b.*,\1\B)
```
[Try it online!](https://tio.run/##HY0xDsIwEAR7vwKJIDlxFPnOTnQ1DZ@wEERQ0FAgSv5ubrcZr@zR@PP8vt73foqXW2@PFIYppFvbo0gaY5MxtT0McpDhqP50jYtfz01@bV8mP9t57F22WTQ4tYJi3BksZF2D6CwbCEfpKB2lo3C0wgGVNNAdZyHRMXaMPxprxo6xY@xkdjI7GQ62gehkOIVOoVPoFDrYGXSnrnBABd3BNu4MlvwH "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
\d+
$*
```
Convert to unary.
```
+`\b(11+)(\1)+\b
$1 1$#2$*
```
Factorise with the smallest prime factors last.
```
^(.+)(,\1|\b.*,\1\B)
```
Compare lexicographically.
[Answer]
# [Python 2](https://docs.python.org/2/), \$\omega^{10}\$, 48 bytes
```
lambda*l:cmp(*[(sorted(`n`)[::-1],n)for n in l])
```
[Try it online!](https://tio.run/##Ncw9CoAgGADQvVM4@oWBNgpewrUE7ccK9FPMpdNbSwd4Lz/1TDg2r@YWXFw21we5xkz7id6p1H2jFi1MUg7CMASfCkFyIQkGmlbF4bFTwQTnHLpcLqw/0@xrlAdoLw "Python 2 – Try It Online")
Outputs `-1` for `<` and `+1` for `>`
Takes each number and sorts its digits in descending order, then compares lexicographically. This effectively compares the count of digit 9's, tiebroken by the number of count 8's, and so on down to 0's. This is all tiebroken by the value of the number itself.
This having order type \$\omega^{10}\$ follows the same argument as my [Haskell \$\omega^{10}\$ answer](https://codegolf.stackexchange.com/a/237304/20260), with sorting replacing taking the running minimum.
[Answer]
# [Haskell](https://www.haskell.org/), \$\omega^\omega\$,62 53 bytes
```
i#0=[i]
i#a=(i+1)#sum[1|'0'<-show a]++[a]
a&b=1#a<1#b
```
[Try it online!](https://tio.run/##PY69CsIwFEb3PEUgYpViSPbeRRSXLkK3kOFGK720aWuTIkLfPf6Art85cL4GQ1t3XSI/DlPk9xk7ulF95QeMKEsKMZFQYMgyEggbyvVWhNkbvWQqK3ahGR4cbZ4btAzXDrTAQguXLoMfOXK3IICD43n5wLJivx1OFfNIPYwT9XH1z8nw/rF/8q9ntJRaKWXTCw)
*-9 bytes thanks to xnor*
Conceptually, this transforms an integer into an infinite list, that is made by iterating `sum[1|'0'<-show a]`, which just counts the zeroes, until zero is reached. Then it's just zeroes after that. Then those lists are then compared in reverse lexicographic order.
To actually do that in practice, the lists are constructed in reverse, and the head of the list is it's own length. The "ideal" infinite lists have an infinite trail of zeroes, which are removed in the "practical" ones. These zeroes are accounted for with the length.
For example, the number `100_000_000_001` has the "ideal" representation `[100_000_000_001,10,1,0,0,0,...]` and the "practical" representation `[4, 1, 10, 100_000_000_001]`
]