GithubHelp home page GithubHelp logo

oleksiyrudenko / stalin-sort Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 0.0 1.53 MB

A repressive sorting algorithm (not really sorting)

Home Page: https://www.npmjs.com/package/@rudenko/stalin-sort

License: MIT License

JavaScript 100.00%
stalin-sort stalinsort educational-project kottans data-repression algorithm npm-module nodejs

stalin-sort's Introduction

stalinSort

Inspired by a post on mastodon

Developed for educational purposes within kottans

Installation

  • npm: npm install --save @rudenko/stalin-sort
  • yarn: yarn add @rudenko/stalin-sort

Usage

const stalinSort = require('@rudenko/stalin-sort')

const numbers = [5, 2, 18, 1];
const strings = ['klm', 'nop', 'def', 'abc']
let result

try {
  result = stalinSort(numbers) // [5, 18]
} catch (e) {
  // handle exception TypeError('Argument must be an array')
}

try {
  result = stalinSort(strings, (a, b) => a > b) // ['klm', 'def', 'abc']
} catch (e) {
  // handle exceptions:
  // - TypeError('Argument must be an array')
  // - TypeError('Comparator must be a function')
}

See example.js for more examples.

Educational

Advance from version to version to track the development process.

See also CHANGELOG.md

Version Milestone Comment Diff
0.0.1 Initialize project
0.0.2 Add code stub and basic test Tests fail v0.0.1...v0.0.2
0.0.3 Add positive scenarios test set Tests still fail v0.0.2...v0.0.3
0.1.0 Add for loop implementation Tests succeed v0.0.3...v0.1.0
0.1.1 Change implementation using for...in loop Tests succeed v0.1.0...v0.1.1
0.1.2 Change implementation using for...of loop Tests succeed v0.1.1...v0.1.2
0.2.0 Change implementation using Array.forEach Tests succeed v0.1.2...v0.2.0
0.3.0 Change implementation using Array.reduce Tests succeed v0.2.0...v0.3.0
0.4.0 Change implementation using Array.filter Tests succeed v0.3.0...v0.4.0
0.4.1 Change Array.filter condition (skip boolean literals) Tests succeed v0.4.0...v0.4.1
0.4.2 Change Array.filter condition (distill logic) Tests succeed v0.4.1...v0.4.2
0.5.0 Add error handling on wrong argument type Tests succeed v0.4.2...v0.5.0
0.6.0 Add compare argument and pre-defined comparators Tests succeed v0.5.0...v0.6.0
0.7.0 Add usage and example.js Tests succeed v0.6.0...v0.7.0
0.8.0 Fix stalinSort implementation logical mistake Tests succeed v0.7.0...v0.8.0
0.8.1 Add tests for comparison functions from utils Tests succeed v0.8.0...v0.8.1

Similar projects

Misc

Time spent: apx 2hrs

stalin-sort's People

Contributors

dependabot[bot] avatar oleksiyrudenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stalin-sort's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.