Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phette23/semester-sort
NPM package for sorting academic semester/quarter strings
https://github.com/phette23/semester-sort
Last synced: 27 days ago
JSON representation
NPM package for sorting academic semester/quarter strings
- Host: GitHub
- URL: https://github.com/phette23/semester-sort
- Owner: phette23
- Created: 2015-09-16T21:13:30.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2023-10-25T21:59:47.000Z (about 1 year ago)
- Last Synced: 2024-08-30T23:56:40.862Z (2 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/semester-sort
- Size: 1.02 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Semester Sort
![Node.js CI](https://github.com/phette23/semester-sort/workflows/Node.js%20CI/badge.svg)
[![NPM Version](https://img.shields.io/npm/v/semester-sort.svg?style=flat-square)](https://npmjs.org/package/semester-sort)JavaScript comparison function, for use with `Array.prototype.sort`, for sorting strings that appear to be academic semesters, e.g. "F15" or "2020 Summer". It recognizes a variety of different ways of describing semesters or quarters, including single-letter abbreviations like "F" to full seasons such as "Autumn".
## Usage
```js
const semesterSort = require('semester-sort')let sorted = ['F15', 'Su15', 'F14', 'F13', 'SP15', 'SP13'].sort(semesterSort)
// returns ['SP13', 'F13', 'F14', 'SP15', 'Su15', 'F15']
```Unrecognized seasons or strings missing a year component will be sorted to the front of the array.
## Development
Write a test for it! The pattern should be easy enough to figure out from test/tests.js and `npm test` runs the test suite.
The code is written in ES6 & transpiled to ES5 via [Babel](http://babeljs.io). `npm run babel` will compile the code in the "src" directory to an index.js in the root, while you can build a minified, browser-ready version of semester-sort with `npm run browser`, which runs index.js through [browserify](https://github.com/substack/node-browserify) and uglifyJS2, outputting a file named "browser.min.js".
## License
![General Public License version 3](https://www.gnu.org/graphics/gplv3-127x51.png)
[GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)