Sort inventory subcomponents
Sort the inventory subcomponents by alphanumeric.
This sorting produces:
"core 0, core 1, core 2,... core 12, core 13"
Before the order was
"core 0, core 1, core 10, core 11, ... core 2, core 21"
Tested: Verified the order
Change-Id: I470684d39e5f6c850368b43fde8073b03556dd12
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index c8a7969..bc89eb1 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -998,6 +998,12 @@
data.title = title;
hardwareData[componentIndex].sub_components.push(data);
hardwareData[componentIndex].search_text += " " + title.toLowerCase();
+
+ // Sort the subcomponents alphanumeric so they are displayed on the
+ // inventory page in order (e.g. core 0, core 1, core 2, ... core 12, core 13)
+ hardwareData[componentIndex].sub_components.sort(function (a, b) {
+ return a.title.localeCompare(b.title, 'en', { numeric: true });
+ });
}
}
}