Browse Source

add materials sorting

Konstantin Ladutenko 5 years ago
parent
commit
f1f9043ded
1 changed files with 8 additions and 3 deletions
  1. 8 3
      vue-cli3-webapp/src/components/GetMaterials.vue

+ 8 - 3
vue-cli3-webapp/src/components/GetMaterials.vue

@@ -66,8 +66,8 @@
             }
         },
         mounted() {
-            let files = ['Ag-Johnson-1972.yml','Au-Johnson-1972.yml'];
-            let names = ['Ag (Silver) Johnson', 'Au (Gold) Johnson'];
+            let files = ['Au-Johnson-1972.yml','Ag-Johnson-1972.yml'];
+            let names = ['Au (Gold) Johnson','Ag (Silver) Johnson'];
             let old_names=[];
             for (const mat of this.materials) old_names.push(mat.name);
             for (let i = 0; i < files.length; i++) {
@@ -80,7 +80,12 @@
                     isLoaded: false
                 });
             }
-            console.log(this.materials)
+            this.sortMaterials();
+        },
+        methods: {
+            sortMaterials() {
+                this.materials.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0));
+            }
         },
         props: ['materials']
     }