1.0.4 • Published 3 years ago

sort-clf v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

sort

sortByKey, sortNumber, sortString, sortBool, sortDateTime

NPM JavaScript Style Guide

Install

npm install --save sort-clf

Usage and example

const moment = require("moment");
const {sortNumber, sortBool, sortString, sortDateTime, sortByKey} = require('sort-clf')

// example sortNumber
const orderNumber = sortNumber([3, 6, 87, 2, 4, 2, 5, 7, 8], 'asc');
console.log({orderNumber})

// example sortBool
const orderBool = sortBool([true, false, false, true, true, false, false, true, false], 'asc');
console.log({orderBool})

// example sortString
const orderString = sortString(['true', 'fae', undefined, null, 'false', 'sdf', 'ghfdgfg', '', 'nsaS', '', null], 'asc');
console.log({orderString})

// example sortDateTime
const orderDateTime = sortDateTime([
  moment().format(), moment().subtract(1,
    "minutes").format(), moment().add(1, "minutes").format(),
  moment().subtract(1, "minutes").format(),
  moment().add(1, "day").format(),
  moment().add(12, "day").format(),
  moment().subtract(12, "day").format()], 'asc');
console.log({orderDateTime})

// example orderByKey
const arrayDate = [
  {start: moment().format()},
  {start: moment().subtract(1, "minutes").format()},
  {start: moment().add(1, "minutes").format()},
  {start: moment().subtract(1, "minutes").format()},
  {start: moment().add(1, "day").format()},
  {start: moment().add(12, "day").format()},
  {start: moment().subtract(12, "day").format()}]
const arrayNum = [{num: 1}, {num: 2}, {num: 0}, {num: -34}, {num: 2}, {num: 2313}, {num: null}]
const orderByKey = sortByKey(arrayDate, "start", false, 'asc');
console.log({orderByKey})

License

MIT © datnv1098 Clasfunc

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago