var fs = require('fs');
// Read the input from the file
var input = fs.readFileSync('input.txt').toString().trim();
// Convert the input into an array of numbers
var array = input.split('\n').map(Number).filter(Boolean);
// Sort the array in ascending order
var sortedArray = array.sort((a, b) => a - b);
// Print each element in the sorted array
sortedArray.forEach(num => console.log(num));
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter