Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mapmeld/myanmar-sort
Big module for NodeJS to sort any Myanmar/Burmese text
https://github.com/mapmeld/myanmar-sort
Last synced: 27 days ago
JSON representation
Big module for NodeJS to sort any Myanmar/Burmese text
- Host: GitHub
- URL: https://github.com/mapmeld/myanmar-sort
- Owner: mapmeld
- Created: 2015-09-23T15:22:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-12T21:57:00.000Z (about 7 years ago)
- Last Synced: 2024-09-15T22:42:40.799Z (3 months ago)
- Language: Ruby
- Homepage: https://www.npmjs.com/package/myanmar-sort
- Size: 5.54 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- Awesome-Myanmar - myanmar-sort
README
# myanmar-sort
Sorting Myanmar / Burmese text is hard! This uses a big JSON tree to help you quickly sort in JavaScript.
If you are sorting names, use the myanmar-names module instead! It will remove prefixes before passing them to this module.
## Usage
If you are on the client-side, don't load this huge library! Use ```new Intl.Collator(["my-MM", "my"])``` instead! Unfortunately Intl.Collator and the Myanmar locale are often not supported.
On the server-side, you can skip this module by installing Node with full locale support (```brew reinstall node --with-full-icu```) or follow instructions on how to add more locales to your current install with ```npm install -g full-icu```.
```bash
npm install myanmar-sort
``````javascript
var myanmarSort = require("myanmar-sort");place1 = 'ရခိုင်ပြည်နယ်';
place2 = 'ရန်ကုန်တိုင်းဒေသကြီး';
place3 = 'ရှမ်းပြည်နယ်';
[place1, place2, place3].sort(myanmarSort);
```You can also pass a function to retrieve the text that you sort by:
```javascript
states = [
{ name: 'ရခိုင်ပြည်နယ်' },
{ name: 'ချင်းပြည်နယ်' },
{ name: 'ရှမ်းပြည်နယ်' }
];
states.sort(myanmarSort(function (state) {
return state.name;
}));
```## Contributions and bugs
The JSON tree isn't complete! Please let me know if you find bugs, and add mocha tests to test/index.js
## License
Open source under an MIT license