sortifyjs
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

SortifyJS

npm version

sortifyjs sorts object keys alphabetically into new array.

Install as an NPM module

$ npm install sortifyjs

Usage

import { createSort } from 'sortifyjs'

or

const { createSort } = require('sortifyjs');

How to use

Basic

interface DataType {
    year: number;
    name: string;
}

const data: DataType[] = [
    {
        year: 25,
        name: "Ana"
    },
    {
        year: 50,
        name: "Thomas"
    },
    {
        year: 18,
        name: "Louise"
    },
    {
        year: 20,
        name: "Alex"
    },
]

createSort<DataType[]>({
    data: data,
    sortBy: "year",
    order: "DESC"
})

Output

[
    {
        year: 50,
        name: "Thomas"
    },
    {
        year: 25,
        name: "Ana"
    },
    {
        year: 20,
        name: "Alex"
    },
    {
        year: 18,
        name: "Louise"
    },
]

Package Sidebar

Install

npm i sortifyjs

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

4.93 kB

Total Files

8

Last publish

Collaborators

  • codrrdev