File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -810,6 +810,7 @@ export default {
810
810
}
811
811
}
812
812
this .nodes = utils .getUnique (this .nodes , ' key' )
813
+ this .nodes = utils .sortByKey (this .nodes , ' key' )
813
814
resolve ()
814
815
}).catch ((error ) => {
815
816
console .log (error)
Original file line number Diff line number Diff line change @@ -19,6 +19,22 @@ function getUnique (arr, comp) {
19
19
return unique
20
20
}
21
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
+
22
37
export {
23
- getUnique
38
+ getUnique ,
39
+ sortByKey
24
40
}
You can’t perform that action at this time.
0 commit comments