nano-ordinals
Tiny ordinal ↔ cardinal converter — ~1 KB, zero deps.
1 → 1st, 2 → 2nd, 11 → 11th, -3 → -3rd … and back. Perfect for code-golf, minimal containers, or just for fun.
✨ Features
- ✅ Cardinal → ordinal (English suffix rules incl.
11/12/13 → th) - ✅ Ordinal → cardinal (case-insensitive:
21st,101ST,42nd) - ✅ Negative numbers supported (
-3 → -3rd) - ✅ Zero dependencies, single tiny file; CLI included
🚀 Usage
# Local (from repo)
python app_min.py 1 # 1st
python app_min.py 11 # 11th
python app_min.py -3 # -3rd
python app_min.py 21st # 21
After installing:
# CLI
pip install nano-ordinals
nano-ordinals 42 # -> 42nd
nano-ordinals 101 # -> 101st
nano-ordinals 101st # -> 101
🤓 Why so small?
- Minimal suffix rule: th unless endswith 1/2/3 and not 11/12/13
- Tiny regex: ([+-]?\d+)(st|nd|rd|th)?
- Single tiny file + tiny CLI: perfect for scripts, containers, CI.
🎉 Fun Ideas
- Generate a calendar day label
date +%d | sed 's/^0//' | xargs nano-ordinals # 1 -> 1st, 21 -> 21st
(Get-Date).Day | % { nano-ordinals $_ } # 14 -> 14th
- Ordinal list (1..20)
seq 1 20 | xargs -I{} nano-ordinals {}
1..20 | % { nano-ordinals $_ }
- Rankings / leaderboards
for n in 1 2 3 4; do echo "Player $n: $(nano-ordinals $n) place"; done
# Player 1: 1st place, Player 2: 2nd place, ...
- Git commit count → ordinal
nano-ordinals $(git rev-list --count HEAD)
# e.g., 42 -> 42nd commit
- Rename files with ordinal indices
i=1; for f in *.png; do mv "$f" "$(nano-ordinals $i)-$f"; i=$((i+1)); done
# 1st-image.png, 2nd-image.png, ...
- Sort plain ordinal tokens numerically
# lines like: 1st, 21st, 3rd...
awk '{print $0 "|" system("nano-ordinals "$0)}' ordinals.txt >/dev/null # sanity check
paste <(cat ordinals.txt) <(sed 's/$//' ordinals.txt | xargs -n1 nano-ordinals) \
| sort -k2,2n | cut -f1
- Reverse conversion (ordinal → number)
for x in 21st 101st 42nd; do echo "$x -> $(nano-ordinals $x)"; done
# 21st -> 21, 101st -> 101, 42nd -> 42
**Tip: Input that contains letters is treated as ordinal → cardinal; digits-only is cardinal → ordinal.
📜 License
MIT © 2025
Metadata
Release files for nano-ordinals 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nano_ordinals-0.1.0.tar.gz | 3.6 kB | Without provenance | Details for nano_ordinals-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nano_ordinals-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nano_ordinals-0.1.0-py3-none-any.whl |
Total release size: 7.6 kB
Release files / nano_ordinals-0.1.0.tar.gz
| Download URL | nano_ordinals-0.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1333d4b968d392735a54b28c4dcfdf3f3b18c5a1690064be2719e79e0788a01d
|
|
BLAKE2b-256 checksum How to use checksums |
43831839ec99d15bbd0f72ef4a9aba340c4322169e714c243f310b8b134d15e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / nano_ordinals-0.1.0-py3-none-any.whl
| Download URL | nano_ordinals-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
488db9d0e19e475716898478675d1cbefcfe5755ea9df6fd584c54b7fd047fec
|
|
BLAKE2b-256 checksum How to use checksums |
79f846cc5f72affc49ac646d4dbb211e7f015a1010c2036e7daeef47fbd8a59b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for nano-ordinals 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.