diff --git a/.gitignore b/.gitignore index 21d3b519..39eb7e66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ dist node_modules - .env* -.DS_Store -src/.DS_Store +.npmrc diff --git a/src/components/trays/model-selection/catalogItems.js b/src/components/trays/model-selection/catalogItems.js index 87389881..602a6393 100644 --- a/src/components/trays/model-selection/catalogItems.js +++ b/src/components/trays/model-selection/catalogItems.js @@ -146,6 +146,12 @@ export default function CatalogItems(data) { } // return all the data cards else { + // get the sorting parameter + const sortParam = (data.isTropical) ? 'advisory_number' : 'cycle'; + + // simple sort comparer for more than 1 level of strings + const compare = (x, y) => (x > y) - (x < y); + // render the results of the data query return ( @@ -172,7 +178,8 @@ export default function CatalogItems(data) { // filter by the group name, get the top 1 .filter((val, idx, self) => ( idx === self.findIndex((t)=> ( t['group'] === val['group']) ))) - .sort((a, b) => a.properties['product_name'] < b.properties['product_name'] ? -1 : 1) + .sort((a, b) => compare(b.properties[sortParam], a.properties[sortParam]) || compare(a.properties['event_type'], b.properties['event_type'])) + //((b.properties[sortParam] + b.properties['event_type']).localeCompare(a.properties[sortParam] + a.properties['event_type']))) // output summarized details of each group member .map((mbr, mbrIdx) => ( // create the checkbox