Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pyomo/common/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def tostr(value, quote_str=False):
}


def tabular_writer(ostream, prefix, data, header, row_generator):
def tabular_writer(ostream, prefix, data, header, row_generator, sort_rows=True):
"""Output data in tabular form

Parameters
Expand All @@ -121,7 +121,8 @@ def tabular_writer(ostream, prefix, data, header, row_generator):
returns either a tuple defining the entries for a single row, or
a generator that returns a sequence of table rows to be output
for the specified `key`

sort_rows: bool
sets if rows should be sorted using robust_sort, default (True)
"""

prefix = tostr(prefix)
Expand Down Expand Up @@ -186,7 +187,9 @@ def tabular_writer(ostream, prefix, data, header, row_generator):

if any(' ' in r[-1] for x in _rows.values() if x is not None for r in x):
_width[-1] = '%s'
for _key in sorted_robust(_rows):
if sort_rows:
_rows=sorted_robust(_rows)
for _key in _rows:
_rowSet = _rows[_key]
if not _rowSet:
_rowSet = [[_key] + [None] * (len(_width) - 1)]
Expand Down