Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stscoundrel/old-norse-alphabet-sort
Sort arrays by Old Norse alphabet
https://github.com/stscoundrel/old-norse-alphabet-sort
alphabet medieval-languages nodejs old-icelandic old-norse sorting
Last synced: 11 days ago
JSON representation
Sort arrays by Old Norse alphabet
- Host: GitHub
- URL: https://github.com/stscoundrel/old-norse-alphabet-sort
- Owner: stscoundrel
- License: mit
- Created: 2020-12-21T13:07:27.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-28T17:50:36.000Z (about 2 months ago)
- Last Synced: 2024-09-28T17:55:09.926Z (about 2 months ago)
- Topics: alphabet, medieval-languages, nodejs, old-icelandic, old-norse, sorting
- Language: TypeScript
- Homepage:
- Size: 1.03 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Old Norse Alphabet Sort
Sort arrays by Old Norse alphabet in Node.js.
Usually localeCompare() or Intl.Collator() is enough to get alphabetical order, but there are edge cases like Icelandic and Old Norse alphabets. LocaleCompare seems to have hard time properly telling apart letters like a, æ or á. This package provides custom sorter for getting old norse alphabetical order just right.
Depends on [Old Norse Alphabet](https://github.com/stscoundrel/old-norse-alphabet) package.
### Install
`yarn add old-norse-alphabet-sort`
### Usage
With simple arrays:
```javascript
const { oldNorseSort } = require('old-norse-alphabet-sort')const words = ['öðli', 'ógnan', 'æðrask', 'aðili', 'þakkan', 'áfir', 'él-ligr', 'ef-lauss', 'œgir', 'maðr']
const sortedWords = [...words].sort((a, b) => oldNorseSort(a, b))
// ['aðili', 'áfir', 'ef-lauss', 'él-ligr', 'maðr', 'ógnan', 'þakkan', 'æðrask', 'œgir', 'öðli']```
With arrays of objects:
```javascript
const { oldNorseSort } = require('old-norse-alphabet-sort')const words = [
{
word: 'æðrask',
definitions: [...]
},
{
word: 'af-burðr',
definitions: [...],
}
]const sortedWords = [...words].sort((a, b) => oldNorseSort(a.word, b.word))
```
### About Old Norse
[Old Norse](https://en.wikipedia.org/wiki/Old_Norse) was a North Germanic language that was spoken by inhabitants of Scandinavia and their overseas settlements from about the 7th to the 15th centuries.