@cloudcmd/sortify

Sort directory content by name, size, date

Usage no npm install needed!

<script type="module">
  import cloudcmdSortify from 'https://cdn.skypack.dev/@cloudcmd/sortify';
</script>

README

Sortify License NPM version Dependency Status Build Status Coverage Status

Sort directory content received by readify by name, size, date.

Install

npm i @cloudcmd/sortify

API

sortify(options, files)

  • options - object can contain:
    • sort - sort by: name, size, date
    • order - "asc" or "desc" for ascending and descending order (default: "asc")
  • files - files list

Examples

const files = [{
    name: 'readify.js',
    size: 3735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file',
}, {
    name: 'sortify.js',
    size: 4735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file',
}];

const sort = 'size';
const order ='desc';

sortify({sort, order}, files);
// output
[{
    name: 'sortify.js',
    size: 4735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file'
}, {
    name: 'readify.js',
    size: 3735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file'
}]

License

MIT