JSPM

js-sortify

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q17304F
    • License MIT

    This package lets you sort your array in ascending or descending order with many different algorithms.

    Package Exports

    • js-sortify
    • js-sortify/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-sortify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    sortify-js Library

    This npm package includes various sorting algorithms. Users can sort an array by providing an array and a sorting order (ascending - "asc" or descending - "desc").

    Installation

        npm install sortify-js
        # or
        yarn add sortify-js

    Usage

    1. Importing the Library:

      const sortify = require("sortify-js");
      // or
      import { quickSort, isSorted } from "sortify-js";
    2. Example Usage:

      const sortedArray = sortify.quickSort(array, "asc");
      // or
      const sortedArray = quickSort(array, "asc");
      
      console.log(sortedArray);

    Supported Sorting Algorithms

    All functions below returns the sorted array

    1. bubbleSort(array, sortOrder = 'asc')
    2. insertionSort(array, sortOrder = 'asc')
    3. selectionSort(array, sortOrder = 'asc')
    4. mergeSort(array, sortOrder = 'asc')
    5. quickSort(array, sortOrder = 'asc')
    6. heapSort(array, sortOrder = 'asc')
    7. radixSort(array, sortOrder = 'asc')
    8. shellSort(array, sortOrder = 'asc')
    9. cocktailSort(array, sortOrder = 'asc')
    10. bogoSort(array, sortOrder = 'asc')

    Helper Functions

    1. shuffle(array): Used to shuffle an array.
    2. isSorted(array, sortOrder): Checks if an array is sorted. (Returns True or False)

    Parameters

    • array (Array)
    • sortOrder (String) - 'asc' or 'desc' ('asc' by default)

    Contact

    Feel free to reach out for any questions or suggestions.