diff --git a/counterparty-core/counterpartycore/lib/api/queries.py b/counterparty-core/counterpartycore/lib/api/queries.py index b40124142..90fed8a28 100644 --- a/counterparty-core/counterpartycore/lib/api/queries.py +++ b/counterparty-core/counterpartycore/lib/api/queries.py @@ -286,7 +286,9 @@ def select_rows( sort_order = "ASC" if sort_order.upper() not in ["ASC", "DESC"]: sort_order = "ASC" - if sort_name in SUPPORTED_SORT_FIELDS.get(table, []): + if sort_name == "asset": + order_by.append(f"COALESCE(asset_longname, asset) {sort_order.upper()}") + elif sort_name in SUPPORTED_SORT_FIELDS.get(table, []): order_by.append(f"{sort_name} {sort_order.upper()}") if len(order_by) == 0: order_by.append(f"{cursor_field} {order}")