README
Sortify
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, dateorder
- "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