New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

dogsort

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dogsort

A hybrid sorting algorithm based on Quicksort and Average Sort

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
4
-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

Dogsort 🐶

Status: Work in Progress

Dogsort is an in-place sorting algorithm (additional required memory is O(1)) with an average complexity of O(N*logN) (the worst complexity is currently under investigation but is guaranteed to be not greater than O(N^2)). It combines Quicksort and Average Sort (https://www.cscjournals.org/manuscript/Journals/IJEA/Volume2/Issue2/IJEA-16.pdf).

⚠️ This project has Work in Progress status. It passes all tests the author has written but it is not guaranteed to pass all edge cases. Please use with caution.

Comparison with other algorithms

Dogsort is more than twice faster than V8 implementation of Array.sort in average for arrays that have size more than 1024 elements (see Roadmap). It also beats Timsort on random arrays but still dramatically loses on sorted arrays just yet, which is expected (see Roadmap). Here are some crude results on arrays of 10^6 size:

Array TypeArray.sort (V8)Timsort
Random: A lot of repeating elements25%29%
Random: Few or no repeating elements28%96%
Ordered: Perfect natural sequence22%1339%
Ordered: Numbers are close to each other16%5707%
Ordered: Numbers are 10^index9%5%
Reverse ordered23%1381%

Install

npm install dogsort --save

Include

NodeJS

const dogsort = require('dogsort');

Browser

<script src='node_modules/dogsort/build/dogsort.js' type='text/javascript'></script>

...or use ES6 import or EMD

Use

const array = [2, 8.88, -7, 90, 0, 120000, -3.455555]

dogsort(array)
console.log(array)

Roadmap

  • Improve performance for small arrays
  • Improve performance for sorted arrays
  • Add a possibility for a custom comparison function
  • Change recursion to stack to save memory if performance is not sacrificed

Keywords

sorting

FAQs

Package last updated on 25 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts