added sorting for input files