отсортировать используя var sort = require('sort-stream')
дает ошибку output is not defined
var fs = require('fs');
var request = require("request");
var parse = require('csv-parse');
var sort = require('sort-stream')
var lineReader = require('readline').createInterface({
input: fs.createReadStream('./tickers.txt')
});
console.log('Ticker'+ ' '+'Price');
lineReader.on('line', function (line) {
var baseURL = 'http://ichart.finance.yahoo.com/table.csv?s=';
var requestURL = baseURL + line;
request(requestURL, function(error, response, body) {
var stockData = body;
parse(stockData, {delimiter: ','}, function(err, output){
var lastEntry = output[1].toString();
var lastEntryArray= lastEntry.toString().split(",");
var adjustedClose = lastEntryArray[lastEntryArray.length-1];
var output = line + " " + adjustedClose;
console.log(output)
});
}).pipe(sort(function(a,b){
if (a < b) return -1;
if (a > b) return 1;
return 0;
})).pipe(output);
});