This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sort5 uses `sort -k3,3`, and process the response sent to stdout | |
////////////////////////////////////////////////////////////////////////////////////// | |
var fs = require('fs'), | |
util = require('util'), | |
spawn = require('child_process').spawn, | |
sort = spawn('sort', ['-k3,3', './input.txt']); | |
var start = Date.now(); | |
var writer = fs.createWriteStream('out5.txt'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sort -k 3,3 input.txt > out4.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sort3 uses nedb, as suggested by Tamas Hegedus | |
////////////////////////////////////////////////////////////////////////////////////// | |
var fs = require('fs'), | |
readline = require('readline'); | |
var Datastore = require('nedb'); | |
var db = new Datastore({ | |
filename: 'path/to/temp/datafile', | |
autoload: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sort2 uses sort-stream, as suggested by Joe Krill | |
////////////////////////////////////////////////////////////////////////////////////// | |
var fs = require('fs'); | |
var sort = require('sort-stream'); | |
var parse = require('csv-parse'); | |
var transform = require('stream-transform'); | |
var start = Date.now(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sort1 uses a straightforward approach, sorting the records in a in-memory array | |
////////////////////////////////////////////////////////////////////////////////////// | |
var fs = require('fs'), | |
readline = require('readline'), | |
stream = require('stream'); | |
var start = Date.now(); | |