array-objects-sort

0.1.0 • Public • Published

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);

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i array-objects-sort

      Weekly Downloads

      0

      Version

      0.1.0

      License

      ISC

      Unpacked Size

      3.75 kB

      Total Files

      3

      Last publish

      Collaborators

      • lequanghuylc