Add log, fix sort, add outputs for CSV and text.