properly sorts output based on filename