Package Exports
- external-sorting
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (external-sorting) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
External Sorting
For my work I needed an external sorting algorithm to sort big arrays (for example: sort 32 array of ~300MB with 2GB of RAM at the same time), but I haven't found any resource which talks about this kind of solution for NodeJS, so I've created it, I've decided to share this part of my project with the community and I hope that the community will help me to improve my solution.
Quick examples
asc sort of strings separate with \n
import fs from 'fs';
import esort from 'external-sorting';
esort({
input: fs.createReadStream('input_file'),
output: fs.createWriteStream('output_file'),
tempDir: __dirname,
maxHeap: 100
})
.asc()
.then(() => {
console.log('done');
})
.catch(console.error);
desc sort of numbers separate with \n
import fs from 'fs';
import esort from 'external-sorting';
await esort({
input: fs.createReadStream('input_file'),
output: fs.createWriteStream('output_file'),
tempDir: __dirname,
deserializer: parseFloat,
serializer: (v: number) => v.toString(10),
maxHeap: 100
})
.desc()
.then(() => {
console.log('done');
})
.catch(console.error);
asc sort of objects by property a.b.c
separate with \r\n
import fs from 'fs';
import esort from 'external-sorting';
await esort({
input: fs.createReadStream('input_file'),
output: fs.createWriteStream('output_file'),
tempDir: __dirname,
deserializer: JSON.parse,
serializer: JSON.stringify,
delimiter: '\r\n',
maxHeap: 100
})
.asc((obj) => obj.a.b.c)
.then(() => {
console.log('done');
})
.catch(console.error);
TODO
- add unit tests (WIP)
- add benchmark
- support
.by
of fast-sort - add ability to sort by multi properties
- add a better docs
Credits
Thanks to @snovakovic for the fast-sort package, you can find it on NPM or GitHub
License
This project is licensed under the MIT License - see the LICENSE file for details