Skip to content

Commit

Permalink
Natural integer sorting for extra fields
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Jul 6, 2022
1 parent f395b8a commit 2f38736
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions InteractiveHtmlBom/core/ibom.py
Expand Up @@ -148,6 +148,21 @@ def natural_sort(lst):

bom_table = []

# If some extra fields are just integers then convert the whole column
# so that sorting will work naturally
for i, field in enumerate(config.show_fields):
if field in ["Value", "Footprint"]:
continue
all_num = True
for f in index_to_fields.values():
if not f[i].isdigit() and len(f[i].strip()) > 0:
all_num = False
break
if all_num:
for f in index_to_fields.values():
if f[i].isdigit():
f[i] = int(f[i])

for _, refs in part_groups.items():
# Fixup values to normalized string
if "Value" in group_by and "Value" in config.show_fields:
Expand Down

0 comments on commit 2f38736

Please sign in to comment.