diff --git a/hub/services/views/pricelist.py b/hub/services/views/pricelist.py index 4d12ee1..34d34b6 100644 --- a/hub/services/views/pricelist.py +++ b/hub/services/views/pricelist.py @@ -7,10 +7,11 @@ from django.contrib.admin.views.decorators import staff_member_required from django.db import models -def natural_sort_key(name): - """Extract numeric part from compute plan name for natural sorting""" - match = re.search(r"compute-std-(\d+)", name) - return int(match.group(1)) if match else 0 +def natural_sort_key(obj): + """Extract numeric parts for natural sorting (works for any plan name)""" + name = obj.name if hasattr(obj, 'name') else str(obj) + parts = re.split(r"(\d+)", name) + return [int(part) if part.isdigit() else part for part in parts] def get_external_price_comparisons(plan, appcat_price, currency, service_level): @@ -150,7 +151,7 @@ def pricelist(request): key=lambda p: ( p.group.order if p.group else 999, p.group.name if p.group else "ZZZ", - natural_sort_key(p.name), + natural_sort_key(p), ), )