def __parsefile(self, input_file, sort_method, ascending_check,
                    sort_by_value):
        # checks for sorting method and creates object accordingly
        if sort_method == "1":
            exp_list = SortedList(ascending_check)
        elif sort_method == "2":
            exp_list = []

        for i in range(len(input_file)):
            try:
                input_file[i].replace(' ', '')
                expression = Expression(input_file[i])
                expression.parse_tree()
                expression.set_sort_value(sort_by_value)
            except Exception as e:
                print("\nInvalid expression at line " + str(i + 1) +
                      ". Skipping expression")
                print(e)
                continue
            if sort_method == "1":
                exp_list.insert(expression)
            elif sort_method == "2":
                exp_list.append(expression)

        if sort_method == "2":
            sort_expressions(exp_list, ascending_check)
        return exp_list