diff --git a/mathics/builtin/list/eol.py b/mathics/builtin/list/eol.py index 9d12e1b62..33de0d754 100644 --- a/mathics/builtin/list/eol.py +++ b/mathics/builtin/list/eol.py @@ -368,10 +368,15 @@ def eval(self, expr, positions, evaluation): ) return + elements = positions.elements + if len(elements) == 0: + return expr + # Create new python list of the positions and sort it + positions = ( - [t for t in positions.elements] - if positions.elements[0].has_form("List", None) + [t for t in elements] + if isinstance(elements[0], ListExpression) else [positions] ) positions.sort(key=lambda e: e.get_sort_key(pattern_sort=True))