We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23842d7 commit 85a6da4Copy full SHA for 85a6da4
src/pages/Index.vue
@@ -810,6 +810,7 @@ export default {
810
}
811
812
this.nodes = utils.getUnique(this.nodes, 'key')
813
+ this.nodes = utils.sortByKey(this.nodes, 'key')
814
resolve()
815
}).catch((error) => {
816
console.log(error)
src/util/utils.js
@@ -19,6 +19,22 @@ function getUnique (arr, comp) {
19
return unique
20
21
22
+/**
23
+ * Sort array of object by key field
24
+ *
25
+ * @param {*} array
26
+ * @param {*} key
27
+ * @returns {Array} Sorted Array
28
+ */
29
+function sortByKey (array, key) {
30
+ return array.sort(function (a, b) {
31
+ var x = a[key]
32
+ var y = b[key]
33
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0))
34
+ })
35
+}
36
+
37
export {
- getUnique
38
+ getUnique,
39
+ sortByKey
40
0 commit comments