0.1.0 • Published 6 years ago

array-objects-sort v0.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

array-objects-sort

  • Sort with many priorities
  • Sort with descending and ascending

usage

Example list:

    const list = [
        {  
            a: "string",
            b: "number",
            c: "string",
            d: "string",
            e: "string"
        }
    ]

Usage:

    const SortList = require("array-objects-sort");

    const options = [
        {
            key: "a",
            priority: ["value_of_a_will_sort_at_top", "value_of_a_behind", "value_of_a_behind", ...]
        },
        {
            key: "b",
            priority: ["desc"] // ["asc"]
        },
        {
            key: "c",
            priority: ["value_of_c", ["this_two_value", "will_be_treated_as_equal_while_sorting"] , ...]
        },
    ];

    const thisSort = new SortList(options);
    const newSortedList = thisSort.sort(list);
    console.log(newSortedList);